﻿#Include Once "windows.bi"
#Include Once "win\ocidl.bi"
#Include Once "crt\string.bi"
 



Dim Shared xywh_library_auto_memory As Any Ptr



#Define DM_CID      "{26037A0E-7CBD-4FFF-9C63-56F2D0770214}"
#Define DM_IID      "{F3F54BC2-D6D1-4A85-B943-16287ECEA64C}"
#Define DM_PATH    ExePath & "\dm.dll"



Function GetDllObject(ByVal hdll As HANDLE,ByVal ClsID As ZString Ptr,ByVal iid As ZString Ptr,ByRef Obj as Any Ptr) as HRESULT
   Dim Func_DllGetClassObject As Function(ByVal As CLSID Ptr, ByVal As Const IID Ptr,ByVal As Any Ptr) As HRESULT
   Dim ClassID As CLSID
   Dim InterfaceID As IID
   Dim picf As iclassfactory Ptr
   Func_DllGetClassObject = Cast(Any Ptr,GetProcAddress(hDll,"DllGetClassObject"))
   CLSIDFromString(*ClsID,@ClassID)
   IIDFromString(*iid,@InterfaceID)
   Dim RetCode As scode = Func_DllGetClassObject(@ClassID, @IID_IClassFactory, @picf)
   If RetCode = s_ok Then
      RetCode = picf->lpvtbl->CreateInstance(picf,NULL,@InterfaceID,@Obj)
      picf->lpvtbl->release(picf)
   EndIf
   Return RetCode
End Function

' 将普通 Ascii 字符串转换为 BStr , 需要使用 SysFreeString(BStrPtr) 释放
Function ToBStr(ZStrPtr As ZString Ptr) As BSTR
   Dim sRet As BSTR
   Dim nLen As Integer
   nLen = MultiByteToWideChar(CP_ACP,0,ZStrPtr,-1,NULL,0)
   sRet = SysAllocStringLen(NULL,nLen)
   MultiByteToWideChar(CP_ACP,0,ZStrPtr,-1,sRet,nLen)
   Return sRet
End Function

' UnicodeToAsci
Function UnicodeToAsci(WStrPtr As Wstring Ptr,WStrLen As UInteger) As ZString Ptr
   If WStrPtr Then
      If WStrLen = 0 Then
         WStrLen = wcslen(WStrPtr)
      EndIf
      Dim ZStrLen As Integer = WideCharToMultiByte(CP_ACP,0,WStrPtr,WStrLen,NULL,0,NULL,NULL)
      Dim ZStrMem As ZString Ptr = Allocate(ZStrLen+1)
      WideCharToMultiByte(CP_ACP,0,WStrPtr,WStrLen,ZStrMem,ZStrLen,NULL,NULL)
      ZStrMem[ZStrLen] = 0
      Return ZStrMem
   EndIf
End Function

' AsciToUnicode
Function AsciToUnicode(ZStrPtr As ZString Ptr,ZStrLen As UInteger) As Wstring Ptr
   If ZStrPtr Then
      If ZStrLen = 0 Then
         ZStrLen = strlen(ZStrPtr)
      EndIf
      Dim WStrLen As Integer = MultiByteToWideChar(CP_ACP,0,ZStrPtr,ZStrLen,NULL,0)
      Dim WStrMem As WString Ptr = Allocate(WStrLen*SizeOf(WString)+2)
      MultiByteToWideChar(CP_ACP,0,ZStrPtr,ZStrLen,WStrMem,WStrLen)
      WStrMem[WStrLen] = 0
      Return WStrMem
   EndIf
End Function

' 自动管理内存的 UnicodeToAsci
Function W2A(UStr As Wstring Ptr,ULen As UInteger=0) As ZString Ptr
   DeAllocate(xywh_library_auto_memory)
   xywh_library_auto_memory = UnicodeToAsci(UStr,ULen)
   Return xywh_library_auto_memory
End Function

' 自动管理内存的 AsciToUnicode
Function A2W(AStr As ZString Ptr,ALen As UInteger=0) As WString Ptr
   DeAllocate(xywh_library_auto_memory)
   xywh_library_auto_memory = AsciToUnicode(AStr,ALen)
   Return xywh_library_auto_memory
End Function





Type dmsoft
   ' 全局数据
   hDll As HANDLE                     ' Dll 句柄
   IsInit As Integer                  ' 是否已初始化
   dmobj As dmsoft_obj                  ' 大漠对象
   nRet As Integer                     ' 上次执行函数的整数返回值
   fRet As Single                     ' 上次执行函数的单精度浮点数返回值
   dRet As Double                     ' 上次执行函数的双精度浮点数返回值
   sRet As BSTR                     ' 上次执行函数的文字返回值
   xywh_library_auto_memory As Any Ptr      ' 内存管理
   
   ' 构造和析构
   Declare Constructor()
   Declare Destructor()
   
   ' 函数封装
   Declare Function Ver() As ZString Ptr
   Declare Function SetPath(path As ZString Ptr) As Integer
   Declare Function Ocr(x1 As Integer, y1 As Integer, x2 As Integer, y2 As Integer, scolor As ZString Ptr, sim As Double) As ZString Ptr
   Declare Function FindStr(x1 As Integer, y1 As Integer, x2 As Integer, y2 As Integer, fstr As ZString Ptr, scolor As ZString Ptr, sim As Double, ByRef x As Integer, ByRef y As Integer) As Integer
   Declare Function GetResultCount(fstr As ZString Ptr) As Integer
   Declare Function GetResultPos(fstr As ZString Ptr, index As Integer, ByRef x As Integer, ByRef y As Integer) As Integer
   Declare Function StrStr(s As ZString Ptr, pStr As ZString Ptr) As Integer
   Declare Function SendCommand(cmd As ZString Ptr) As Integer
   Declare Function UseDict(index As Integer) As Integer
   Declare Function GetBasePath() As ZString Ptr
   Declare Function SetDictPwd(pwd As ZString Ptr) As Integer
   Declare Function OcrInFile(x1 As Integer, y1 As Integer, x2 As Integer, y2 As Integer, pic_name As ZString Ptr, scolor As ZString Ptr, sim As Double) As ZString Ptr
   Declare Function Capture(x1 As Integer, y1 As Integer, x2 As Integer, y2 As Integer, file As ZString Ptr) As Integer
   Declare Function KeyPress(vk As Integer) As Integer
   Declare Function KeyDown(vk As Integer) As Integer
   Declare Function KeyUp(vk As Integer) As Integer
   Declare Function LeftClick() As Integer
   Declare Function RightClick() As Integer
   Declare Function MiddleClick() As Integer
   Declare Function LeftDoubleClick() As Integer
   Declare Function LeftDown() As Integer
   Declare Function LeftUp() As Integer
   Declare Function RightDown() As Integer
   Declare Function RightUp() As Integer
   Declare Function MoveTo(x As Integer, y As Integer) As Integer
   Declare Function MoveR(rx As Integer, ry As Integer) As Integer
   Declare Function GetColor(x As Integer, y As Integer) As ZString Ptr
   Declare Function GetColorBGR(x As Integer, y As Integer) As ZString Ptr
   Declare Function RGB2BGR(rgb_color As ZString Ptr) As ZString Ptr
   Declare Function BGR2RGB(bgr_color As ZString Ptr) As ZString Ptr
   Declare Function UnBindWindow() As Integer
   Declare Function CmpColor(x As Integer, y As Integer, fcolor As ZString Ptr, sim As Double) As Integer
   Declare Function ClientToScreen(hWin As HWND, ByRef x As Integer, ByRef y As Integer) As Integer
   Declare Function ScreenToClient(hWin As HWND, ByRef x As Integer, ByRef y As Integer) As Integer
   Declare Function ShowScrMsg(x1 As Integer, y1 As Integer, x2 As Integer, y2 As Integer,msg As ZString Ptr, fcolor As ZString Ptr) As Integer
   Declare Function SetMinRowGap(row_gap As Integer) As Integer
   Declare Function SetMinColGap(col_gap As Integer) As Integer
   Declare Function FindColor(x1 As Integer, y1 As Integer, x2 As Integer, y2 As Integer, fcolor As ZString Ptr, sim As Double, idir As Integer, ByRef x As Integer, ByRef y As Integer) As Integer
   Declare Function FindColorEx(x1 As Integer, y1 As Integer, x2 As Integer, y2 As Integer, fcolor As ZString Ptr, sim As Double, idir As Integer) As ZString Ptr
   Declare Function SetWordLineHeight(line_height As Integer) As Integer
   Declare Function SetWordGap(word_gap As Integer) As Integer
   Declare Function SetRowGapNoDict(row_gap As Integer) As Integer
   Declare Function SetColGapNoDict(col_gap As Integer) As Integer
   Declare Function SetWordLineHeightNoDict(line_height As Integer) As Integer
   Declare Function SetWordGapNoDict(word_gap As Integer) As Integer
   Declare Function GetWordResultCount(fstr As ZString Ptr) As Integer
   Declare Function GetWordResultPos(fstr As ZString Ptr, index As Integer, ByRef x As Integer, ByRef y As Integer) As Integer
   Declare Function GetWordResultStr(fstr As ZString Ptr, index As Integer) As ZString Ptr
   Declare Function GetWords(x1 As Integer, y1 As Integer, x2 As Integer, y2 As Integer, fcolor As ZString Ptr, sim As Double) As ZString Ptr
   Declare Function GetWordsNoDict(x1 As Integer, y1 As Integer, x2 As Integer, y2 As Integer, fcolor As ZString Ptr) As ZString Ptr
   Declare Function SetShowErrorMsg(show As Integer) As Integer
   Declare Function GetClientSize(hWin As HWND, ByRef w As Integer, ByRef h As Integer) As Integer
   Declare Function MoveWindow(hWin As HWND, x As Integer, y As Integer) As Integer
   Declare Function GetColorHSV(x As Integer, y As Integer) As ZString Ptr
   Declare Function GetAveRGB(x1 As Integer, y1 As Integer, x2 As Integer, y2 As Integer) As ZString Ptr
   Declare Function GetAveHSV(x1 As Integer, y1 As Integer, x2 As Integer, y2 As Integer) As ZString Ptr
   Declare Function GetForegroundWindow() As HWND
   Declare Function GetForegroundFocus() As HWND
   Declare Function GetMousePointWindow() As HWND
   Declare Function GetPointWindow(x As Integer, y As Integer) As HWND
   Declare Function EnumWindow(parent As Integer, title As ZString Ptr, class_name As ZString Ptr, filter As Integer) As ZString Ptr
   Declare Function GetWindowState(hWin As HWND, flag As Integer) As Integer
   Declare Function GetWindow(hWin As HWND, flag As Integer) As HWND
   Declare Function GetSpecialWindow(flag As Integer) As HWND
   Declare Function SetWindowText(hWin As HWND, text As ZString Ptr) As Integer
   Declare Function SetWindowSize(hWin As HWND, w As Integer, h As Integer) As Integer
   Declare Function GetWindowRect(hWin As HWND, ByRef x1 As Integer, ByRef y1 As Integer, ByRef x2 As Integer, ByRef y2 As Integer) As Integer
   Declare Function GetWindowTitle(hWin As HWND) As ZString Ptr
   Declare Function GetWindowClass(hWin As HWND) As ZString Ptr
   Declare Function SetWindowState(hWin As HWND, flag As Integer) As Integer
   Declare Function CreateFoobarRect(hWin As HWND, x As Integer, y As Integer, w As Integer, h As Integer) As Integer
   Declare Function CreateFoobarRoundRect(hWin As HWND, x As Integer, y As Integer, w As Integer, h As Integer, rw As Integer, rh As Integer) As Integer
   Declare Function CreateFoobarEllipse(hWin As HWND, x As Integer, y As Integer, w As Integer, h As Integer) As Integer
   Declare Function CreateFoobarCustom(hWin As HWND, x As Integer, y As Integer, pic As ZString Ptr, trans_color As ZString Ptr, sim As Double) As Integer
   Declare Function FoobarFillRect(hWin As HWND, x1 As Integer, y1 As Integer, x2 As Integer, y2 As Integer, scolor As ZString Ptr) As Integer
   Declare Function FoobarDrawText(hWin As HWND, x As Integer, y As Integer, w As Integer, h As Integer, text As ZString Ptr, scolor As ZString Ptr, align As Integer) As Integer
   Declare Function FoobarDrawPic(hWin As HWND, x As Integer, y As Integer, pic As ZString Ptr, trans_color As ZString Ptr) As Integer
   Declare Function FoobarUpdate(hWin As HWND) As Integer
   Declare Function FoobarLock(hWin As HWND) As Integer
   Declare Function FoobarUnlock(hWin As HWND) As Integer
   Declare Function FoobarSetFont(hWin As HWND, font_name As ZString Ptr, size As Integer, flag As Integer) As Integer
   Declare Function FoobarTextRect(hWin As HWND, x As Integer, y As Integer, w As Integer, h As Integer) As Integer
   Declare Function FoobarPrintText(hWin As HWND, text As ZString Ptr, scolor As ZString Ptr) As Integer
   Declare Function FoobarClearText(hWin As HWND) As Integer
   Declare Function FoobarTextLineGap(hWin As HWND, gap As Integer) As Integer
   Declare Function Play(file As ZString Ptr) As Integer
   Declare Function FaqCapture(x1 As Integer, y1 As Integer, x2 As Integer, y2 As Integer, quality As Integer, idelay As Integer, iTime As Integer) As Integer
   Declare Function FaqRelease(handle As Integer) As Integer
   Declare Function FaqSend(server As ZString Ptr, handle As Integer, request_type As Integer, time_out As Integer) As ZString Ptr
   Declare Function Beep(iFre As Integer, idelay As Integer) As Integer
   Declare Function FoobarClose(hWin As HWND) As Integer
   Declare Function MoveDD(dx As Integer, dy As Integer) As Integer
   Declare Function FaqGetSize(handle As Integer) As Integer
   Declare Function LoadPic(pic_name As ZString Ptr) As Integer
   Declare Function FreePic(pic_name As ZString Ptr) As Integer
   Declare Function GetScreenData(x1 As Integer, y1 As Integer, x2 As Integer, y2 As Integer) As Integer
   Declare Function FreeScreenData(handle As Integer) As Integer
   Declare Function WheelUp() As Integer
   Declare Function WheelDown() As Integer
   Declare Function SetMouseDelay(tpe As ZString Ptr, idelay As Integer) As Integer
   Declare Function SetKeypadDelay(tpe As ZString Ptr, idelay As Integer) As Integer
   Declare Function GetEnv(index As Integer, sname As ZString Ptr) As ZString Ptr
   Declare Function SetEnv(index As Integer, sname As ZString Ptr, value As ZString Ptr) As Integer
   Declare Function SendString(hWin As HWND, sStr As ZString Ptr) As Integer
   Declare Function DelEnv(index As Integer, sname As ZString Ptr) As Integer
   Declare Function GetPath() As ZString Ptr
   Declare Function SetDict(index As Integer, dict_name As ZString Ptr) As Integer
   Declare Function FindPic(x1 As Integer, y1 As Integer, x2 As Integer, y2 As Integer, pic_name As ZString Ptr, delta_color As ZString Ptr, sim As Double, iDir As Integer, ByRef x As Integer, ByRef y As Integer) As Integer
   Declare Function FindPicEx(x1 As Integer, y1 As Integer, x2 As Integer, y2 As Integer, pic_name As ZString Ptr, delta_color As ZString Ptr, sim As Double, iDir As Integer) As ZString Ptr
   Declare Function SetClientSize(hWin As HWND, w As Integer, h As Integer) As Integer
   Declare Function ReadInt(hWin As HWND, addr As ZString Ptr, tpe As Integer) As Integer
   Declare Function ReadFloat(hWin As HWND, addr As ZString Ptr) As Single
   Declare Function ReadDouble(hWin As HWND, addr As ZString Ptr) As Double
   Declare Function FindInt(hWin As HWND, addr_range As ZString Ptr, int_value_min As Integer, int_value_max As Integer, tpe As Integer) As ZString Ptr
   Declare Function FindFloat(hWin As HWND, addr_range As ZString Ptr, float_value_min As Single, float_value_max As Single) As ZString Ptr
   Declare Function FindDouble(hWin As HWND, addr_range As ZString Ptr, double_value_min As Double, double_value_max As Double) As ZString Ptr
   Declare Function FindString(hWin As HWND, addr_range As ZString Ptr, string_value As ZString Ptr, tpe As Integer) As ZString Ptr
   Declare Function GetModuleBaseAddr(hWin As HWND, module_name As ZString Ptr) As Integer
   Declare Function MoveToEx(x As Integer, y As Integer, w As Integer, h As Integer) As ZString Ptr
   Declare Function MatchPicName(pic_name As ZString Ptr) As ZString Ptr
   Declare Function AddDict(index As Integer, dict_info As ZString Ptr) As Integer
   Declare Function EnterCri() As Integer
   Declare Function LeaveCri() As Integer
   Declare Function WriteInt(hWin As HWND, addr As ZString Ptr, tpe As Integer, v As Integer) As Integer
   Declare Function WriteFloat(hWin As HWND, addr As ZString Ptr, v As Single) As Integer
   Declare Function WriteDouble(hWin As HWND, addr As ZString Ptr, v As Double) As Integer
   Declare Function WriteString(hWin As HWND, addr As ZString Ptr, tpe As Integer, v As ZString Ptr) As Integer
   Declare Function AsmAdd(asm_ins As ZString Ptr) As Integer
   Declare Function AsmClear() As Integer
   Declare Function AsmCall(hWin As HWND, mode As Integer) As Integer
   Declare Function FindMultiColor(x1 As Integer, y1 As Integer, x2 As Integer, y2 As Integer, first_color As ZString Ptr, offset_color As ZString Ptr, sim As Double, iDir As Integer, ByRef x As Integer, ByRef y As Integer) As Integer
   Declare Function FindMultiColorEx(x1 As Integer, y1 As Integer, x2 As Integer, y2 As Integer, first_color As ZString Ptr, offset_color As ZString Ptr, sim As Double, iDir As Integer) As ZString Ptr
   Declare Function AsmCode(base_addr As Integer) As ZString Ptr
   Declare Function Assemble(asm_code As ZString Ptr, base_addr As Integer, is_upper As Integer) As ZString Ptr
   Declare Function SetWindowTransparent(hWin As HWND, v As Integer) As Integer
   Declare Function ReadData(hWin As HWND, addr As ZString Ptr, nLen As Integer) As ZString Ptr
   Declare Function WriteData(hWin As HWND, addr As ZString Ptr, pData As ZString Ptr) As Integer
   Declare Function FindData(hWin As HWND, addr_range As ZString Ptr, pData As ZString Ptr) As ZString Ptr
   Declare Function SetPicPwd(pwd As ZString Ptr) As Integer
   Declare Function Log(info As ZString Ptr) As Integer
   Declare Function SetExactOcr(exact_ocr As Integer) As Integer
   'FindStrE As Function(x1 As long,y1 As long,x2 As long,y2 As long,str As BSTR,color As BSTR,sim As double,ret As BSTR Ptr) As HRESULT     'method FindStrE
   'FindColorE As Function(x1 As long,y1 As long,x2 As long,y2 As long,color As BSTR,sim As double,dir As long,ret As BSTR Ptr) As HRESULT     'method FindColorE
   'FindPicE As Function(x1 As long,y1 As long,x2 As long,y2 As long,pic_name As BSTR,delta_color As BSTR,sim As double,dir As long,ret As BSTR Ptr) As HRESULT     'method FindPicE
   'FindMultiColorE As Function(x1 As long,y1 As long,x2 As long,y2 As long,first_color As BSTR,offset_color As BSTR,sim As double,dir As long,ret As BSTR Ptr) As HRESULT     'method FindMultiColorE
   Declare Function ReadString(hWin As HWND, addr As ZString Ptr, tpe As Integer, nLen As Integer) As ZString Ptr
   Declare Function FoobarTextPrintDir(hWin As HWND, iDir As Integer) As Integer
   Declare Function OcrEx(x1 As Integer, y1 As Integer, x2 As Integer, y2 As Integer, scolor As ZString Ptr, sim As Double) As ZString Ptr
   Declare Function SetDisplayInput(mode As ZString Ptr) As Integer
   Declare Function GetTime() As Integer
   Declare Function GetScreenWidth() As Integer
   Declare Function GetScreenHeight() As Integer
   Declare Function BindWindowEx(hWin As HWND, display As ZString Ptr, mouse As ZString Ptr, keypad As ZString Ptr, public_desc As ZString Ptr, mode As Integer) As Integer
   Declare Function GetDiskSerial() As ZString Ptr
   Declare Function Md5(pStr As ZString Ptr) As ZString Ptr
   Declare Function GetMac() As ZString Ptr
   Declare Function ActiveInputMethod(hWin As HWND, id As ZString Ptr) As Integer
   Declare Function CheckInputMethod(hWin As HWND, id As ZString Ptr) As Integer
   Declare Function FindInputMethod(id As ZString Ptr) As Integer
   Declare Function GetCursorPos(ByRef x As Integer, ByRef y As Integer) As Integer
   Declare Function BindWindow(hWin As HWND, display As ZString Ptr, mouse As ZString Ptr, keypad As ZString Ptr, mode As Integer) As Integer
   Declare Function FindWindow(class_name As ZString Ptr, title_name As ZString Ptr) As HWND
   Declare Function GetScreenDepth() As Integer
   Declare Function SetScreen(w As Integer, h As Integer, depth As Integer) As Integer
   Declare Function ExitOs(tpe As Integer) As Integer
   Declare Function GetDir(tpe As Integer) As ZString Ptr
   Declare Function GetOsType() As Integer
   Declare Function FindWindowEx(parent As HWND, class_name As ZString Ptr, title_name As ZString Ptr) As HWND
   Declare Function SetExportDict(index As Integer, dict_name As ZString Ptr) As Integer
   Declare Function GetCursorShape() As ZString Ptr
   Declare Function DownCpu(rate As Integer) As Integer
   Declare Function GetCursorSpot() As ZString Ptr
   Declare Function SendString2(hWin As HWND, pStr As ZString Ptr) As Integer
   Declare Function FaqPost(server As ZString Ptr, handle As Integer, request_type As Integer, time_out As Integer) As Integer
   Declare Function FaqFetch() As ZString Ptr
   Declare Function FetchWord(x1 As Integer, y1 As Integer, x2 As Integer, y2 As Integer, scolor As ZString Ptr, word As ZString Ptr) As ZString Ptr
   Declare Function CaptureJpg(x1 As Integer, y1 As Integer, x2 As Integer, y2 As Integer, file As ZString Ptr, quality As Integer) As Integer
   Declare Function FindStrWithFont(x1 As Integer, y1 As Integer, x2 As Integer, y2 As Integer, pStr As ZString Ptr, scolor As ZString Ptr, sim As Double, font_name As ZString Ptr, font_size As Integer, flag As Integer, ByRef x As Integer, ByRef y As Integer) As Integer
   'FindStrWithFontE As Function(x1 As long,y1 As long,x2 As long,y2 As long,str As BSTR,color As BSTR,sim As double,font_name As BSTR,font_size As long,flag As long,ret As BSTR Ptr) As HRESULT     'method FindStrWithFontE
   Declare Function FindStrWithFontEx(x1 As Integer, y1 As Integer, x2 As Integer, y2 As Integer, pStr As ZString Ptr, scolor As ZString Ptr, sim As Double, font_name As ZString Ptr, font_size As Integer, flag As Integer) As ZString Ptr
   Declare Function GetDictInfo(pStr As ZString Ptr, font_name As ZString Ptr, font_size As Integer, flag As Integer) As ZString Ptr
   Declare Function SaveDict(index As Integer, file As ZString Ptr) As Integer
   Declare Function GetWindowProcessId(hWin As HWND) As Integer
   Declare Function GetWindowProcessPath(hWin As HWND) As ZString Ptr
   Declare Function LockInput(nLock As Integer) As Integer
   Declare Function GetPicSize(pic_name As ZString Ptr) As ZString Ptr
   Declare Function GetID() As Integer
   Declare Function CapturePng(x1 As Integer, y1 As Integer, x2 As Integer, y2 As Integer, file As ZString Ptr) As Integer
   Declare Function CaptureGif(x1 As Integer, y1 As Integer, x2 As Integer, y2 As Integer, file As ZString Ptr, idelay As Integer, iTime As Integer) As Integer
   Declare Function ImageToBmp(pic_name As ZString Ptr, bmp_name As ZString Ptr) As Integer
   Declare Function FindStrFast(x1 As Integer, y1 As Integer, x2 As Integer, y2 As Integer, pStr As ZString Ptr, scolor As ZString Ptr, sim As Double, ByRef x As Integer, ByRef y As Integer) As Integer
   Declare Function FindStrFastEx(x1 As Integer, y1 As Integer, x2 As Integer, y2 As Integer, pStr As ZString Ptr, scolor As ZString Ptr, sim As Double) As ZString Ptr
   'FindStrFastE As Function(x1 As long,y1 As long,x2 As long,y2 As long,str As BSTR,color As BSTR,sim As double,ret As BSTR Ptr) As HRESULT     'method FindStrFastE
   Declare Function EnableDisplayDebug(enable_debug As Integer) As Integer
   Declare Function CapturePre(file As ZString Ptr) As Integer
   Declare Function RegEx(code As ZString Ptr, sVer As ZString Ptr, ip As ZString Ptr) As Integer
   Declare Function GetMachineCode() As ZString Ptr
   Declare Function SetClipboard(pData As ZString Ptr) As Integer
   Declare Function GetClipboard() As ZString Ptr
   Declare Function GetNowDict() As Integer
   Declare Function Is64Bit() As Integer
   Declare Function GetColorNum(x1 As Integer, y1 As Integer, x2 As Integer, y2 As Integer, scolor As ZString Ptr, sim As Double) As Integer
   Declare Function EnumWindowByProcess(process_name As ZString Ptr, title As ZString Ptr, class_name As ZString Ptr, filter As Integer) As ZString Ptr
   Declare Function GetDictCount(index As Integer) As Integer
   Declare Function GetLastError() As Integer
   Declare Function GetNetTime() As ZString Ptr
   Declare Function EnableGetColorByCapture(en As Integer) As Integer
   Declare Function CheckUAC() As Integer
   Declare Function SetUAC(uac As Integer) As Integer
   Declare Function DisableFontSmooth() As Integer
   Declare Function CheckFontSmooth() As Integer
   Declare Function SetDisplayAcceler(level As Integer) As Integer
   Declare Function FindWindowByProcess(process_name As ZString Ptr, class_name As ZString Ptr, title_name As ZString Ptr) As Integer
   Declare Function FindWindowByProcessId(process_id As Integer, class_name As ZString Ptr, title_name As ZString Ptr) As Integer
   Declare Function ReadIni(section As ZString Ptr, key As ZString Ptr, file As ZString Ptr) As ZString Ptr
   Declare Function WriteIni(section As ZString Ptr, key As ZString Ptr, v As ZString Ptr, file As ZString Ptr) As Integer
   Declare Function RunApp(path As ZString Ptr, mode As Integer) As Integer
   Declare Function delay(mis As Integer) As Integer
   Declare Function FindWindowSuper(spec1 As ZString Ptr, flag1 As Integer, type1 As Integer, spec2 As ZString Ptr, flag2 As Integer, type2 As Integer) As Integer
   Declare Function ExcludePos(all_pos As ZString Ptr, tpe As Integer, x1 As Integer, y1 As Integer, x2 As Integer, y2 As Integer) As ZString Ptr
   Declare Function FindNearestPos(all_pos As ZString Ptr, tpe As Integer, x As Integer, y As Integer) As ZString Ptr
   Declare Function SortPosDistance(all_pos As ZString Ptr, tpe As Integer, x As Integer, y As Integer) As ZString Ptr
   Declare Function FindPicMem(x1 As Integer, y1 As Integer, x2 As Integer, y2 As Integer, pic_info As ZString Ptr, delta_color As ZString Ptr, sim As Double, iDir As Integer, ByRef x As Integer, ByRef y As Integer) As Integer
   Declare Function FindPicMemEx(x1 As Integer, y1 As Integer, x2 As Integer, y2 As Integer, pic_info As ZString Ptr, delta_color As ZString Ptr, sim As Double, iDir As Integer) As ZString Ptr
   'FindPicMemE As Function(x1 As long,y1 As long,x2 As long,y2 As long,pic_info As BSTR,delta_color As BSTR,sim As double,dir As long,ret As BSTR Ptr) As HRESULT     'method FindPicMemE
   Declare Function AppendPicAddr(pic_info As ZString Ptr, addr As Integer, size As Integer) As ZString Ptr
   Declare Function WriteFile(file As ZString Ptr, content As ZString Ptr) As Integer
   Declare Function Stop(id As Integer) As Integer
   Declare Function SetDictMem(index As Integer, addr As Integer, size As Integer) As Integer
   Declare Function GetNetTimeSafe() As ZString Ptr
   Declare Function ForceUnBindWindow(hWin As HWND) As Integer
   Declare Function ReadIniPwd(section As ZString Ptr, key As ZString Ptr, file As ZString Ptr, pwd As ZString Ptr) As ZString Ptr
   Declare Function WriteIniPwd(section As ZString Ptr, key As ZString Ptr, v As ZString Ptr, file As ZString Ptr, pwd As ZString Ptr) As Integer
   Declare Function DecodeFile(file As ZString Ptr, pwd As ZString Ptr) As Integer
   Declare Function KeyDownChar(key_str As ZString Ptr) As Integer
   Declare Function KeyUpChar(key_str As ZString Ptr) As Integer
   Declare Function KeyPressChar(key_str As ZString Ptr) As Integer
   Declare Function KeyPressStr(key_str As ZString Ptr, idelay As Integer) As Integer
   Declare Function EnableKeypadPatch(en As Integer) As Integer
   Declare Function EnableKeypadSync(en As Integer, time_out As Integer) As Integer
   Declare Function EnableMouseSync(en As Integer, time_out As Integer) As Integer
   Declare Function DmGuard(en As Integer, tpe As ZString Ptr) As Integer
   Declare Function FaqCaptureFromFile(x1 As Integer, y1 As Integer, x2 As Integer, y2 As Integer, file As ZString Ptr, quality As Integer) As Integer
   Declare Function FindIntEx(hWin As HWND, addr_range As ZString Ptr, int_value_min As Integer, int_value_max As Integer, tpe As Integer, Stp As Integer, multi_thread As Integer, mode As Integer) As ZString Ptr
   Declare Function FindFloatEx(hWin As HWND, addr_range As ZString Ptr, float_value_min As Single, float_value_max As Single, Stp As Integer, multi_thread As Integer, mode As Integer) As ZString Ptr
   Declare Function FindDoubleEx(hWin As HWND, addr_range As ZString Ptr, double_value_min As Double, double_value_max As Double, Stp As Integer, multi_thread As Integer, mode As Integer) As ZString Ptr
   Declare Function FindStringEx(hWin As HWND, addr_range As ZString Ptr, string_value As ZString Ptr, tpe As Integer, Stp As Integer, multi_thread As Integer, mode As Integer) As ZString Ptr
   Declare Function FindDataEx(hWin As HWND, addr_range As ZString Ptr, pData As ZString Ptr, stp As Integer, multi_thread As Integer, mode As Integer) As ZString Ptr
   Declare Function EnableRealMouse(en As Integer, mousedelay As Integer, mousestep As Integer) As Integer
   Declare Function EnableRealKeypad(en As Integer) As Integer
   Declare Function SendStringIme(pStr As ZString Ptr) As Integer
   Declare Function FoobarDrawLine(hWin As HWND, x1 As Integer, y1 As Integer, x2 As Integer, y2 As Integer, scolor As ZString Ptr, style As Integer, w As Integer) As Integer
   Declare Function FindStrEx(x1 As Integer, y1 As Integer, x2 As Integer, y2 As Integer, pStr As ZString Ptr, scolor As ZString Ptr, sim As Double) As ZString Ptr
   Declare Function IsBind(hWin As HWND) As Integer
   Declare Function SetDisplayDelay(t As Integer) As Integer
   Declare Function GetDmCount() As Integer
   Declare Function DisableScreenSave() As Integer
   Declare Function DisablePowerSave() As Integer
   Declare Function SetMemoryHwndAsProcessId(en As Integer) As Integer
   Declare Function FindShape(x1 As Integer, y1 As Integer, x2 As Integer, y2 As Integer, offset_color As ZString Ptr, sim As Double, iDir As Integer, ByRef x As Integer, ByRef y As Integer) As Integer
   'FindShapeE As Function(x1 As long,y1 As long,x2 As long,y2 As long,offset_color As BSTR,sim As double,dir As long,ret As BSTR Ptr) As HRESULT     'method FindShapeE
   Declare Function FindShapeEx(x1 As Integer, y1 As Integer, x2 As Integer, y2 As Integer, offset_color As ZString Ptr, sim As Double, iDir As Integer) As ZString Ptr
   Declare Function FindStrS(x1 As Integer, y1 As Integer, x2 As Integer, y2 As Integer, pStr As ZString Ptr, scolor As ZString Ptr, sim As Double, ByRef x As Integer, ByRef y As Integer) As ZString Ptr
   Declare Function FindStrExS(x1 As Integer, y1 As Integer, x2 As Integer, y2 As Integer, pStr As ZString Ptr, scolor As ZString Ptr, sim As Double) As ZString Ptr
   Declare Function FindStrFastS(x1 As Integer, y1 As Integer, x2 As Integer, y2 As Integer, pStr As ZString Ptr, scolor As ZString Ptr, sim As Double, ByRef x As Integer, ByRef y As Integer) As ZString Ptr
   Declare Function FindStrFastExS(x1 As Integer, y1 As Integer, x2 As Integer, y2 As Integer, pStr As ZString Ptr, scolor As ZString Ptr, sim As Double) As ZString Ptr
   Declare Function FindPicS(x1 As Integer, y1 As Integer, x2 As Integer, y2 As Integer, pic_name As ZString Ptr, delta_color As ZString Ptr, sim As Double, iDir As Integer, ByRef x As Integer, ByRef y As Integer) As ZString Ptr
   Declare Function FindPicExS(x1 As Integer, y1 As Integer, x2 As Integer, y2 As Integer, pic_name As ZString Ptr, delta_color As ZString Ptr, sim As Double, iDir As Integer) As ZString Ptr
   Declare Function ClearDict(index As Integer) As Integer
   Declare Function GetMachineCodeNoMac() As ZString Ptr
   Declare Function GetClientRect(hWin As HWND, ByRef x1 As Integer, ByRef y1 As Integer, ByRef x2 As Integer, ByRef y2 As Integer) As Integer
   Declare Function EnableFakeActive(en As Integer) As Integer
   Declare Function GetScreenDataBmp(x1 As Integer, y1 As Integer, x2 As Integer, y2 As Integer, ByRef pData As Any Ptr, ByRef size As Integer) As Integer
   Declare Function EncodeFile(file As ZString Ptr, pwd As ZString Ptr) As Integer
   Declare Function GetCursorShapeEx(tpe As Integer) As ZString Ptr
   Declare Function FaqCancel() As Integer
   Declare Function IntToData(int_value As Integer, tpe As Integer) As ZString Ptr
   Declare Function FloatToData(float_value As Single) As ZString Ptr
   Declare Function DoubleToData(double_value As Double) As ZString Ptr
   Declare Function StringToData(string_value As ZString Ptr, tpe As Integer) As ZString Ptr
   Declare Function SetMemoryFindResultToFile(file As ZString Ptr) As Integer
   Declare Function EnableBind(en As Integer) As Integer
   Declare Function SetSimMode(mode As Integer) As Integer
   Declare Function LockMouseRect(x1 As Integer, y1 As Integer, x2 As Integer, y2 As Integer) As Integer
   Declare Function SendPaste(hWin As HWND) As Integer
   Declare Function IsDisplayDead(x1 As Integer, y1 As Integer, x2 As Integer, y2 As Integer, t As Integer) As Integer
   Declare Function GetKeyState(vk As Integer) As Integer
   Declare Function CopyFile(src_file As ZString Ptr, dst_file As ZString Ptr, over As Integer) As Integer
   Declare Function IsFileExist(file As ZString Ptr) As Integer
   Declare Function DeleteFile(file As ZString Ptr) As Integer
   Declare Function MoveFile(src_file As ZString Ptr, dst_file As ZString Ptr) As Integer
   Declare Function CreateFolder(folder_name As ZString Ptr) As Integer
   Declare Function DeleteFolder(folder_name As ZString Ptr) As Integer
   Declare Function GetFileLength(file As ZString Ptr) As Integer
   Declare Function ReadFile(file As ZString Ptr) As ZString Ptr
   Declare Function WaitKey(key_code As Integer, time_out As Integer) As Integer
   Declare Function DeleteIni(section As ZString Ptr, key As ZString Ptr, file As ZString Ptr) As Integer
   Declare Function DeleteIniPwd(section As ZString Ptr, key As ZString Ptr, file As ZString Ptr, pwd As ZString Ptr) As Integer
   Declare Function EnableSpeedDx(en As Integer) As Integer
   Declare Function EnableIme(en As Integer) As Integer
   Declare Function Reg(code As ZString Ptr, sVer As ZString Ptr) As Integer
   Declare Function SelectFile() As ZString Ptr
   Declare Function SelectDirectory() As ZString Ptr
   Declare Function LockDisplay(iLock As Integer) As Integer
   Declare Function FoobarSetSave(hWin As HWND, file As ZString Ptr, en As Integer, header As ZString Ptr) As Integer
   Declare Function EnumWindowSuper(spec1 As ZString Ptr, flag1 As Integer, type1 As Integer, spec2 As ZString Ptr, flag2 As Integer, type2 As Integer, sort As Integer) As ZString Ptr
   Declare Function DownloadFile(url As ZString Ptr, save_file As ZString Ptr, timeout As Integer) As Integer
   Declare Function EnableKeypadMsg(en As Integer) As Integer
   Declare Function EnableMouseMsg(en As Integer) As Integer
   Declare Function RegNoMac(code As ZString Ptr, sVer As ZString Ptr) As Integer
   Declare Function RegExNoMac(code As ZString Ptr, sVer As ZString Ptr, ip As ZString Ptr) As Integer
   Declare Function SetEnumWindowDelay(idelay As Integer) As Integer
   Declare Function FindMulColor(x1 As Integer, y1 As Integer, x2 As Integer, y2 As Integer, scolor As ZString Ptr, sim As Double) As Integer
   Declare Function GetDict(index As Integer, font_index As Integer) As ZString Ptr
End Type





Constructor dmsoft()
   hDll = LoadLibrary(DM_PATH)
   If hDll Then
      If GetDllObject(hDll,DM_CID,DM_IID,dmobj) = s_ok Then
         IsInit = TRUE
      EndIf
   EndIf
End Constructor

Destructor dmsoft()
   If dmobj Then
      dmobj->lpvtbl->Release(dmobj)
      dmobj = NULL
   EndIf
   If hDll Then
      FreeLibrary(hDll)
      hDll = NULL
   EndIf
   IsInit = FALSE
End Destructor





' 功能测试 [OK]      内存泄漏测试 [OK]
Function dmsoft.Ver() As ZString Ptr
   If sRet Then
      SysFreeString(sRet)
   EndIf
   dmobj->lpvtbl->Ver(dmobj, @sRet)
   Return W2A(sRet)
End Function

' 内存泄漏测试 [OK]
Function dmsoft.SetPath(path As ZString Ptr) As Integer
   Dim tStr As Any Ptr = ToBStr(path)
   dmobj->lpvtbl->SetPath(dmobj, tStr, @nRet)
   SysFreeString(tStr)
   Return nRet
End Function

Function dmsoft.Ocr(x1 As Integer, y1 As Integer, x2 As Integer, y2 As Integer, scolor As ZString Ptr, sim As Double) As ZString Ptr
   If sRet Then
      SysFreeString(sRet)
   EndIf
   Dim tStr As Any Ptr = ToBStr(scolor)
   dmobj->lpvtbl->Ocr(dmobj, x1, y1, x2, y2, tStr, sim, @sRet)
   SysFreeString(tStr)
   Return W2A(sRet)
End Function

Function dmsoft.FindStr(x1 As Integer, y1 As Integer, x2 As Integer, y2 As Integer, fstr As ZString Ptr, scolor As ZString Ptr, sim As Double, ByRef x As Integer, ByRef y As Integer) As Integer
   Dim As VARIANT tx, ty
   Dim tfStr As Any Ptr = ToBStr(fstr)
   Dim tcStr As Any Ptr = ToBStr(scolor)
   dmobj->lpvtbl->FindStr(dmobj, x1, y1, x2, y2, tfStr, tcStr, sim, @tx, @ty, @nRet)
   x = tx.lVal
   y = ty.lVal
   SysFreeString(tfStr)
   SysFreeString(tcStr)
   Return nRet
End Function

Function dmsoft.GetResultCount(fstr As ZString Ptr) As Integer
   Dim tStr As Any Ptr = ToBStr(fstr)
   dmobj->lpvtbl->GetResultCount(dmobj, tStr, @nRet)
   SysFreeString(tStr)
   Return nRet
End Function

Function dmsoft.GetResultPos(fstr As ZString Ptr, index As Integer, ByRef x As Integer, ByRef y As Integer) As Integer
   Dim As VARIANT tx, ty
   Dim tStr As Any Ptr = ToBStr(fstr)
   dmobj->lpvtbl->GetResultPos(dmobj, tStr, index, @tx, @ty, @nRet)
   x = tx.lVal
   y = ty.lVal
   SysFreeString(tStr)
   Return nRet
End Function

Function dmsoft.StrStr(s As ZString Ptr, pStr As ZString Ptr) As Integer
   Dim tsStr As Any Ptr = ToBStr(s)
   Dim tpStr As Any Ptr = ToBStr(pStr)
   dmobj->lpvtbl->StrStr(dmobj, tsStr, tpStr, @nRet)
   SysFreeString(tsStr)
   SysFreeString(tpStr)
   Return nRet
End Function

Function dmsoft.SendCommand(cmd As ZString Ptr) As Integer
   Dim tStr As Any Ptr = ToBStr(cmd)
   dmobj->lpvtbl->SendCommand(dmobj, tStr, @nRet)
   SysFreeString(tStr)
   Return nRet
End Function

Function dmsoft.UseDict(index As Integer) As Integer
   dmobj->lpvtbl->UseDict(dmobj, index, @nRet)
   Return nRet
End Function

Function dmsoft.GetBasePath() As ZString Ptr
   If sRet Then
      SysFreeString(sRet)
   EndIf
   dmobj->lpvtbl->GetBasePath(dmobj, @sRet)
   Return W2A(sRet)
End Function

Function dmsoft.SetDictPwd(pwd As ZString Ptr) As Integer
   Dim tStr As Any Ptr = ToBStr(pwd)
   dmobj->lpvtbl->SetDictPwd(dmobj, tStr, @nRet)
   SysFreeString(tStr)
   Return nRet
End Function

Function dmsoft.OcrInFile(x1 As Integer, y1 As Integer, x2 As Integer, y2 As Integer, pic_name As ZString Ptr, scolor As ZString Ptr, sim As Double) As ZString Ptr
   If sRet Then
      SysFreeString(sRet)
   EndIf
   Dim tpStr As Any Ptr = ToBStr(pic_name)
   Dim tcStr As Any Ptr = ToBStr(scolor)
   dmobj->lpvtbl->OcrInFile(dmobj, x1, y1, x2, y2, tpStr, tcStr, sim, @sRet)
   SysFreeString(tpStr)
   SysFreeString(tcStr)
   Return W2A(sRet)
End Function

Function dmsoft.Capture(x1 As Integer, y1 As Integer, x2 As Integer, y2 As Integer, file As ZString Ptr) As Integer
   Dim tStr As Any Ptr = ToBStr(file)
   dmobj->lpvtbl->Capture(dmobj, x1, y1, x2, y2, tStr, @nRet)
   SysFreeString(tStr)
   Return nRet
End Function

Function dmsoft.KeyPress(vk As Integer) As Integer
   dmobj->lpvtbl->KeyPress(dmobj, vk, @nRet)
   Return nRet
End Function

Function dmsoft.KeyDown(vk As Integer) As Integer
   dmobj->lpvtbl->KeyDown(dmobj, vk, @nRet)
   Return nRet
End Function

Function dmsoft.KeyUp(vk As Integer) As Integer
   dmobj->lpvtbl->KeyUp(dmobj, vk, @nRet)
   Return nRet
End Function

Function dmsoft.LeftClick() As Integer
   dmobj->lpvtbl->LeftClick(dmobj, @nRet)
   Return nRet
End Function

Function dmsoft.RightClick() As Integer
   dmobj->lpvtbl->RightClick(dmobj, @nRet)
   Return nRet
End Function

Function dmsoft.MiddleClick() As Integer
   dmobj->lpvtbl->MiddleClick(dmobj, @nRet)
   Return nRet
End Function

Function dmsoft.LeftDoubleClick() As Integer
   dmobj->lpvtbl->LeftDoubleClick(dmobj, @nRet)
   Return nRet
End Function

Function dmsoft.LeftDown() As Integer
   dmobj->lpvtbl->LeftDown(dmobj, @nRet)
   Return nRet
End Function

Function dmsoft.LeftUp() As Integer
   dmobj->lpvtbl->LeftUp(dmobj, @nRet)
   Return nRet
End Function

Function dmsoft.RightDown() As Integer
   dmobj->lpvtbl->RightDown(dmobj, @nRet)
   Return nRet
End Function

Function dmsoft.RightUp() As Integer
   dmobj->lpvtbl->RightUp(dmobj, @nRet)
   Return nRet
End Function

Function dmsoft.MoveTo(x As Integer, y As Integer) As Integer
   dmobj->lpvtbl->MoveTo(dmobj, x, y, @nRet)
   Return nRet
End Function

Function dmsoft.MoveR(rx As Integer, ry As Integer) As Integer
   dmobj->lpvtbl->MoveR(dmobj, rx, ry, @nRet)
   Return nRet
End Function

Function dmsoft.GetColor(x As Integer, y As Integer) As ZString Ptr
   If sRet Then
      SysFreeString(sRet)
   EndIf
   dmobj->lpvtbl->GetColor(dmobj, x, y, @sRet)
   Return W2A(sRet)
End Function

Function dmsoft.GetColorBGR(x As Integer, y As Integer) As ZString Ptr
   If sRet Then
      SysFreeString(sRet)
   EndIf
   dmobj->lpvtbl->GetColorBGR(dmobj, x, y, @sRet)
   Return W2A(sRet)
End Function

Function dmsoft.RGB2BGR(rgb_color As ZString Ptr) As ZString Ptr
   If sRet Then
      SysFreeString(sRet)
   EndIf
   Dim tStr As Any Ptr = ToBStr(rgb_color)
   dmobj->lpvtbl->RGB2BGR(dmobj, tStr, @sRet)
   SysFreeString(tStr)
   Return W2A(sRet)
End Function

Function dmsoft.BGR2RGB(bgr_color As ZString Ptr) As ZString Ptr
   If sRet Then
      SysFreeString(sRet)
   EndIf
   Dim tStr As Any Ptr = ToBStr(bgr_color)
   dmobj->lpvtbl->BGR2RGB(dmobj, tStr, @sRet)
   SysFreeString(tStr)
   Return W2A(sRet)
End Function

Function dmsoft.UnBindWindow() As Integer
   dmobj->lpvtbl->UnBindWindow(dmobj, @nRet)
   Return nRet
End Function

Function dmsoft.CmpColor(x As Integer, y As Integer, fcolor As ZString Ptr, sim As Double) As Integer
   Dim tStr As Any Ptr = ToBStr(fcolor)
   dmobj->lpvtbl->CmpColor(dmobj, x, y, tStr, sim, @nRet)
   SysFreeString(tStr)
   Return nRet
End Function

Function dmsoft.ClientToScreen(hWin As HWND, ByRef x As Integer, ByRef y As Integer) As Integer
   Dim As VARIANT tx, ty
   dmobj->lpvtbl->ClientToScreen(dmobj, Cast(Integer, hWin), @tx, @ty, @nRet)
   x = tx.lVal
   y = ty.lVal
   Return nRet
End Function

Function dmsoft.ScreenToClient(hWin As HWND, ByRef x As Integer, ByRef y As Integer) As Integer
   Dim As VARIANT tx, ty
   dmobj->lpvtbl->ScreenToClient(dmobj, Cast(Integer, hWin), @tx, @ty, @nRet)
   x = tx.lVal
   y = ty.lVal
   Return nRet
End Function

Function dmsoft.ShowScrMsg(x1 As Integer, y1 As Integer, x2 As Integer, y2 As Integer,msg As ZString Ptr, fcolor As ZString Ptr) As Integer
   Dim tmStr As Any Ptr = ToBStr(msg)
   Dim tcStr As Any Ptr = ToBStr(fcolor)
   dmobj->lpvtbl->ShowScrMsg(dmobj, x1, y1, x2, y2, tmStr, tcStr, @nRet)
   SysFreeString(tmStr)
   SysFreeString(tcStr)
   Return nRet
End Function

Function dmsoft.SetMinRowGap(row_gap As Integer) As Integer
   dmobj->lpvtbl->SetMinRowGap(dmobj, row_gap, @nRet)
   Return nRet
End Function

Function dmsoft.SetMinColGap(col_gap As Integer) As Integer
   dmobj->lpvtbl->SetMinColGap(dmobj, col_gap, @nRet)
   Return nRet
End Function

Function dmsoft.FindColor(x1 As Integer, y1 As Integer, x2 As Integer, y2 As Integer, fcolor As ZString Ptr, sim As Double, idir As Integer, ByRef x As Integer, ByRef y As Integer) As Integer
   Dim As VARIANT tx, ty
   Dim tStr As Any Ptr = ToBStr(fcolor)
   dmobj->lpvtbl->FindColor(dmobj, x1, y1, x2, y2, tStr, sim, idir, @tx, @ty, @nRet)
   x = tx.lVal
   y = ty.lVal
   SysFreeString(tStr)
   Return nRet
End Function

Function dmsoft.FindColorEx(x1 As Integer, y1 As Integer, x2 As Integer, y2 As Integer, fcolor As ZString Ptr, sim As Double, idir As Integer) As ZString Ptr
   If sRet Then
      SysFreeString(sRet)
   EndIf
   Dim tStr As Any Ptr = ToBStr(fcolor)
   dmobj->lpvtbl->FindColorEx(dmobj, x1, y1, x2, y2, tStr, sim, idir, @sRet)
   SysFreeString(tStr)
   Return W2A(sRet)
End Function

Function dmsoft.SetWordLineHeight(line_height As Integer) As Integer
   dmobj->lpvtbl->SetWordLineHeight(dmobj, line_height, @nRet)
   Return nRet
End Function

Function dmsoft.SetWordGap(word_gap As Integer) As Integer
   dmobj->lpvtbl->SetWordGap(dmobj, word_gap, @nRet)
   Return nRet
End Function

Function dmsoft.SetRowGapNoDict(row_gap As Integer) As Integer
   dmobj->lpvtbl->SetRowGapNoDict(dmobj, row_gap, @nRet)
   Return nRet
End Function

Function dmsoft.SetColGapNoDict(col_gap As Integer) As Integer
   dmobj->lpvtbl->SetColGapNoDict(dmobj, col_gap, @nRet)
   Return nRet
End Function

Function dmsoft.SetWordLineHeightNoDict(line_height As Integer) As Integer
   dmobj->lpvtbl->SetWordLineHeightNoDict(dmobj, line_height, @nRet)
   Return nRet
End Function

Function dmsoft.SetWordGapNoDict(word_gap As Integer) As Integer
   dmobj->lpvtbl->SetWordGapNoDict(dmobj, word_gap, @nRet)
   Return nRet
End Function

Function dmsoft.GetWordResultCount(fstr As ZString Ptr) As Integer
   Dim tStr As Any Ptr = ToBStr(fstr)
   dmobj->lpvtbl->GetWordResultCount(dmobj, tStr, @nRet)
   SysFreeString(tStr)
   Return nRet
End Function

Function dmsoft.GetWordResultPos(fstr As ZString Ptr, index As Integer, ByRef x As Integer, ByRef y As Integer) As Integer
   Dim As VARIANT tx, ty
   Dim tStr As Any Ptr = ToBStr(fstr)
   dmobj->lpvtbl->GetWordResultPos(dmobj, tStr, index, @tx, @ty, @nRet)
   x = tx.lVal
   y = ty.lVal
   SysFreeString(tStr)
   Return nRet
End Function

Function dmsoft.GetWordResultStr(fstr As ZString Ptr, index As Integer) As ZString Ptr
   If sRet Then
      SysFreeString(sRet)
   EndIf
   Dim tStr As Any Ptr = ToBStr(fstr)
   dmobj->lpvtbl->GetWordResultStr(dmobj, tStr, index, @sRet)
   SysFreeString(tStr)
   Return W2A(sRet)
End Function

Function dmsoft.GetWords(x1 As Integer, y1 As Integer, x2 As Integer, y2 As Integer, fcolor As ZString Ptr, sim As Double) As ZString Ptr
   If sRet Then
      SysFreeString(sRet)
   EndIf
   Dim tStr As Any Ptr = ToBStr(fcolor)
   dmobj->lpvtbl->GetWords(dmobj, x1, y1, x2, y2, tStr, sim, @sRet)
   SysFreeString(tStr)
   Return W2A(sRet)
End Function

Function dmsoft.GetWordsNoDict(x1 As Integer, y1 As Integer, x2 As Integer, y2 As Integer, fcolor As ZString Ptr) As ZString Ptr
   If sRet Then
      SysFreeString(sRet)
   EndIf
   Dim tStr As Any Ptr = ToBStr(fcolor)
   dmobj->lpvtbl->GetWordsNoDict(dmobj, x1, y1, x2, y2, tStr, @sRet)
   SysFreeString(tStr)
   Return W2A(sRet)
End Function

Function dmsoft.SetShowErrorMsg(show As Integer) As Integer
   dmobj->lpvtbl->SetShowErrorMsg(dmobj, show, @nRet)
   Return nRet
End Function

Function dmsoft.GetClientSize(hWin As HWND, ByRef w As Integer, ByRef h As Integer) As Integer
   Dim As VARIANT tw, th
   dmobj->lpvtbl->GetClientSize(dmobj, Cast(Integer, hWin), @tw, @th, @nRet)
   w = tw.lVal
   h = th.lVal
   Return nRet
End Function

Function dmsoft.MoveWindow(hWin As HWND, x As Integer, y As Integer) As Integer
   dmobj->lpvtbl->MoveWindow(dmobj, Cast(Integer, hWin), x, y, @nRet)
   Return nRet
End Function

Function dmsoft.GetColorHSV(x As Integer, y As Integer) As ZString Ptr
   If sRet Then
      SysFreeString(sRet)
   EndIf
   dmobj->lpvtbl->GetColorHSV(dmobj, x, y, @sRet)
   Return W2A(sRet)
End Function

Function dmsoft.GetAveRGB(x1 As Integer, y1 As Integer, x2 As Integer, y2 As Integer) As ZString Ptr
   If sRet Then
      SysFreeString(sRet)
   EndIf
   dmobj->lpvtbl->GetAveRGB(dmobj, x1, y1, x2, y2, @sRet)
   Return W2A(sRet)
End Function

Function dmsoft.GetAveHSV(x1 As Integer, y1 As Integer, x2 As Integer, y2 As Integer) As ZString Ptr
   If sRet Then
      SysFreeString(sRet)
   EndIf
   dmobj->lpvtbl->GetAveHSV(dmobj, x1, y1, x2, y2, @sRet)
   Return W2A(sRet)
End Function

Function dmsoft.GetForegroundWindow() As HWND
   dmobj->lpvtbl->GetForegroundWindow(dmobj, @nRet)
   Return Cast(HWND, nRet)
End Function

Function dmsoft.GetForegroundFocus() As HWND
   dmobj->lpvtbl->GetForegroundFocus(dmobj, @nRet)
   Return Cast(HWND, nRet)
End Function

Function dmsoft.GetMousePointWindow() As HWND
   dmobj->lpvtbl->GetMousePointWindow(dmobj, @nRet)
   Return Cast(HWND, nRet)
End Function

Function dmsoft.GetPointWindow(x As Integer, y As Integer) As HWND
   dmobj->lpvtbl->GetPointWindow(dmobj, x, y, @nRet)
   Return Cast(HWND, nRet)
End Function

Function dmsoft.EnumWindow(parent As Integer, title As ZString Ptr, class_name As ZString Ptr, filter As Integer) As ZString Ptr
   If sRet Then
      SysFreeString(sRet)
   EndIf
   Dim ttStr As Any Ptr = ToBStr(title)
   Dim tcStr As Any Ptr = ToBStr(class_name)
   dmobj->lpvtbl->EnumWindow(dmobj, parent, ttStr, tcStr, filter, @sRet)
   SysFreeString(ttStr)
   SysFreeString(tcStr)
   Return W2A(sRet)
End Function

Function dmsoft.GetWindowState(hWin As HWND, flag As Integer) As Integer
   dmobj->lpvtbl->GetWindowState(dmobj, Cast(Integer, hWin), flag, @nRet)
   Return nRet
End Function

Function dmsoft.GetWindow(hWin As HWND, flag As Integer) As HWND
   dmobj->lpvtbl->GetWindow(dmobj, Cast(Integer, hWin), flag, @nRet)
   Return Cast(HWND, nRet)
End Function

Function dmsoft.GetSpecialWindow(flag As Integer) As HWND
   dmobj->lpvtbl->GetSpecialWindow(dmobj, flag, @nRet)
   Return Cast(HWND, nRet)
End Function

Function dmsoft.SetWindowText(hWin As HWND, text As ZString Ptr) As Integer
   Dim tStr As Any Ptr = ToBStr(text)
   dmobj->lpvtbl->SetWindowText(dmobj, Cast(Integer, hWin), tStr, @nRet)
   SysFreeString(tStr)
   Return nRet
End Function

Function dmsoft.SetWindowSize(hWin As HWND, w As Integer, h As Integer) As Integer
   dmobj->lpvtbl->SetWindowSize(dmobj, Cast(Integer, hWin), w, h, @nRet)
   Return nRet
End Function

Function dmsoft.GetWindowRect(hWin As HWND, ByRef x1 As Integer, ByRef y1 As Integer, ByRef x2 As Integer, ByRef y2 As Integer) As Integer
   Dim As VARIANT tx1, tx2, ty1, ty2
   dmobj->lpvtbl->GetWindowRect(dmobj, Cast(Integer, hWin), @tx1, @ty1, @tx2, @ty2, @nRet)
   x1 = tx1.lVal
   y1 = ty1.lVal
   x2 = tx2.lVal
   y2 = ty2.lVal
   Return nRet
End Function

Function dmsoft.GetWindowTitle(hWin As HWND) As ZString Ptr
   If sRet Then
      SysFreeString(sRet)
   EndIf
   dmobj->lpvtbl->GetWindowTitle(dmobj, Cast(Integer, hWin), @sRet)
   Return W2A(sRet)
End Function

Function dmsoft.GetWindowClass(hWin As HWND) As ZString Ptr
   If sRet Then
      SysFreeString(sRet)
   EndIf
   dmobj->lpvtbl->GetWindowClass(dmobj, Cast(Integer, hWin), @sRet)
   Return W2A(sRet)
End Function

Function dmsoft.SetWindowState(hWin As HWND, flag As Integer) As Integer
   dmobj->lpvtbl->SetWindowState(dmobj, Cast(Integer, hWin), flag, @nRet)
   Return nRet
End Function

Function dmsoft.CreateFoobarRect(hWin As HWND, x As Integer, y As Integer, w As Integer, h As Integer) As Integer
   dmobj->lpvtbl->CreateFoobarRect(dmobj, Cast(Integer, hWin), x, y, w, h, @nRet)
   Return nRet
End Function

Function dmsoft.CreateFoobarRoundRect(hWin As HWND, x As Integer, y As Integer, w As Integer, h As Integer, rw As Integer, rh As Integer) As Integer
   dmobj->lpvtbl->CreateFoobarRoundRect(dmobj, Cast(Integer, hWin), x, y, w, h, rw, rh, @nRet)
   Return nRet
End Function

Function dmsoft.CreateFoobarEllipse(hWin As HWND, x As Integer, y As Integer, w As Integer, h As Integer) As Integer
   dmobj->lpvtbl->CreateFoobarEllipse(dmobj, Cast(Integer, hWin), x, y, w, h, @nRet)
   Return nRet
End Function

Function dmsoft.CreateFoobarCustom(hWin As HWND, x As Integer, y As Integer, pic As ZString Ptr, trans_color As ZString Ptr, sim As Double) As Integer
   Dim tpStr As Any Ptr = ToBStr(pic)
   Dim tcStr As Any Ptr = ToBStr(trans_color)
   dmobj->lpvtbl->CreateFoobarCustom(dmobj, Cast(Integer, hWin), x, y, tpStr, tcStr, sim, @nRet)
   SysFreeString(tpStr)
   SysFreeString(tcStr)
   Return nRet
End Function

Function dmsoft.FoobarFillRect(hWin As HWND, x1 As Integer, y1 As Integer, x2 As Integer, y2 As Integer, scolor As ZString Ptr) As Integer
   Dim tStr As Any Ptr = ToBStr(scolor)
   dmobj->lpvtbl->FoobarFillRect(dmobj, Cast(Integer, hWin), x1, y1, x2, y2, tStr, @nRet)
   SysFreeString(tStr)
   Return nRet
End Function

Function dmsoft.FoobarDrawText(hWin As HWND, x As Integer, y As Integer, w As Integer, h As Integer, text As ZString Ptr, scolor As ZString Ptr, align As Integer) As Integer
   Dim tsStr As Any Ptr = ToBStr(text)
   Dim tcStr As Any Ptr = ToBStr(scolor)
   dmobj->lpvtbl->FoobarDrawText(dmobj, Cast(Integer, hWin), x, y, w, h, tsStr, tcStr, align, @nRet)
   SysFreeString(tsStr)
   SysFreeString(tcStr)
   Return nRet
End Function

Function dmsoft.FoobarDrawPic(hWin As HWND, x As Integer, y As Integer, pic As ZString Ptr, trans_color As ZString Ptr) As Integer
   Dim tpStr As Any Ptr = ToBStr(pic)
   Dim tcStr As Any Ptr = ToBStr(trans_color)
   dmobj->lpvtbl->FoobarDrawPic(dmobj, Cast(Integer, hWin), x, y, tpStr, tcStr, @nRet)
   SysFreeString(tpStr)
   SysFreeString(tcStr)
   Return nRet
End Function

Function dmsoft.FoobarUpdate(hWin As HWND) As Integer
   dmobj->lpvtbl->FoobarUpdate(dmobj, Cast(Integer, hWin), @nRet)
   Return nRet
End Function

Function dmsoft.FoobarLock(hWin As HWND) As Integer
   dmobj->lpvtbl->FoobarLock(dmobj, Cast(Integer, hWin), @nRet)
   Return nRet
End Function

Function dmsoft.FoobarUnlock(hWin As HWND) As Integer
   dmobj->lpvtbl->FoobarUnlock(dmobj, Cast(Integer, hWin), @nRet)
   Return nRet
End Function

Function dmsoft.FoobarSetFont(hWin As HWND, font_name As ZString Ptr, size As Integer, flag As Integer) As Integer
   Dim tStr As Any Ptr = ToBStr(font_name)
   dmobj->lpvtbl->FoobarSetFont(dmobj, Cast(Integer, hWin), tStr, size, flag, @nRet)
   SysFreeString(tStr)
   Return nRet
End Function

Function dmsoft.FoobarTextRect(hWin As HWND, x As Integer, y As Integer, w As Integer, h As Integer) As Integer
   dmobj->lpvtbl->FoobarTextRect(dmobj, Cast(Integer, hWin), x, y, w, h, @nRet)
   Return nRet
End Function

Function dmsoft.FoobarPrintText(hWin As HWND, text As ZString Ptr, scolor As ZString Ptr) As Integer
   Dim tsStr As Any Ptr = ToBStr(text)
   Dim tcStr As Any Ptr = ToBStr(scolor)
   dmobj->lpvtbl->FoobarPrintText(dmobj, Cast(Integer, hWin), tsStr, tcStr, @nRet)
   SysFreeString(tsStr)
   SysFreeString(tcStr)
   Return nRet
End Function

Function dmsoft.FoobarClearText(hWin As HWND) As Integer
   dmobj->lpvtbl->FoobarClearText(dmobj, Cast(Integer, hWin), @nRet)
   Return nRet
End Function

Function dmsoft.FoobarTextLineGap(hWin As HWND, gap As Integer) As Integer
   dmobj->lpvtbl->FoobarTextLineGap(dmobj, Cast(Integer, hWin), gap, @nRet)
   Return nRet
End Function

Function dmsoft.Play(file As ZString Ptr) As Integer
   Dim tStr As Any Ptr = ToBStr(file)
   dmobj->lpvtbl->Play(dmobj, tStr, @nRet)
   SysFreeString(tStr)
   Return nRet
End Function

Function dmsoft.FaqCapture(x1 As Integer, y1 As Integer, x2 As Integer, y2 As Integer, quality As Integer, idelay As Integer, iTime As Integer) As Integer
   dmobj->lpvtbl->FaqCapture(dmobj, x1, y1, x2, y2, quality, idelay, iTime, @nRet)
   Return nRet
End Function

Function dmsoft.FaqRelease(handle As Integer) As Integer
   dmobj->lpvtbl->FaqRelease(dmobj, handle, @nRet)
   Return nRet
End Function

Function dmsoft.FaqSend(server As ZString Ptr, handle As Integer, request_type As Integer, time_out As Integer) As ZString Ptr
   If sRet Then
      SysFreeString(sRet)
   EndIf
   Dim tStr As Any Ptr = ToBStr(server)
   dmobj->lpvtbl->FaqSend(dmobj, tStr, handle, request_type, time_out, @sRet)
   SysFreeString(tStr)
   Return W2A(sRet)
End Function

Function dmsoft.Beep(iFre As Integer, idelay As Integer) As Integer
   dmobj->lpvtbl->Beep(dmobj, iFre, idelay, @nRet)
   Return nRet
End Function

Function dmsoft.FoobarClose(hWin As HWND) As Integer
   dmobj->lpvtbl->FoobarClose(dmobj, Cast(Integer, hWin), @nRet)
   Return nRet
End Function

Function dmsoft.MoveDD(dx As Integer, dy As Integer) As Integer
   dmobj->lpvtbl->MoveDD(dmobj, dx, dy, @nRet)
   Return nRet
End Function

Function dmsoft.FaqGetSize(handle As Integer) As Integer
   dmobj->lpvtbl->FaqGetSize(dmobj, handle, @nRet)
   Return nRet
End Function

Function dmsoft.LoadPic(pic_name As ZString Ptr) As Integer
   Dim tStr As Any Ptr = ToBStr(pic_name)
   dmobj->lpvtbl->LoadPic(dmobj, tStr, @nRet)
   SysFreeString(tStr)
   Return nRet
End Function

Function dmsoft.FreePic(pic_name As ZString Ptr) As Integer
   Dim tStr As Any Ptr = ToBStr(pic_name)
   dmobj->lpvtbl->FreePic(dmobj, tStr, @nRet)
   SysFreeString(tStr)
   Return nRet
End Function

Function dmsoft.GetScreenData(x1 As Integer, y1 As Integer, x2 As Integer, y2 As Integer) As Integer
   dmobj->lpvtbl->GetScreenData(dmobj, x1, y1, x2, y2, @nRet)
   Return nRet
End Function

Function dmsoft.FreeScreenData(handle As Integer) As Integer
   dmobj->lpvtbl->FreeScreenData(dmobj, handle, @nRet)
   Return nRet
End Function

Function dmsoft.WheelUp() As Integer
   dmobj->lpvtbl->WheelUp(dmobj, @nRet)
   Return nRet
End Function

Function dmsoft.WheelDown() As Integer
   dmobj->lpvtbl->WheelDown(dmobj, @nRet)
   Return nRet
End Function

Function dmsoft.SetMouseDelay(tpe As ZString Ptr, idelay As Integer) As Integer
   Dim tStr As Any Ptr = ToBStr(tpe)
   dmobj->lpvtbl->SetMouseDelay(dmobj, tStr, idelay, @nRet)
   SysFreeString(tStr)
   Return nRet
End Function

Function dmsoft.SetKeypadDelay(tpe As ZString Ptr, idelay As Integer) As Integer
   Dim tStr As Any Ptr = ToBStr(tpe)
   dmobj->lpvtbl->SetKeypadDelay(dmobj, tStr, idelay, @nRet)
   SysFreeString(tStr)
   Return nRet
End Function

Function dmsoft.GetEnv(index As Integer, sname As ZString Ptr) As ZString Ptr
   If sRet Then
      SysFreeString(sRet)
   EndIf
   Dim tStr As Any Ptr = ToBStr(sname)
   dmobj->lpvtbl->GetEnv(dmobj, index, tStr, @sRet)
   SysFreeString(tStr)
   Return W2A(sRet)
End Function

Function dmsoft.SetEnv(index As Integer, sname As ZString Ptr, value As ZString Ptr) As Integer
   Dim tnStr As Any Ptr = ToBStr(sname)
   Dim tvStr As Any Ptr = ToBStr(sname)
   dmobj->lpvtbl->SetEnv(dmobj, index, tnStr, tvStr, @nRet)
   SysFreeString(tnStr)
   SysFreeString(tvStr)
   Return nRet
End Function

Function dmsoft.SendString(hWin As HWND, sStr As ZString Ptr) As Integer
   Dim tStr As Any Ptr = ToBStr(sStr)
   dmobj->lpvtbl->SendString(dmobj, Cast(Integer, hWin), tStr, @nRet)
   SysFreeString(tStr)
   Return nRet
End Function

Function dmsoft.DelEnv(index As Integer, sname As ZString Ptr) As Integer
   Dim tStr As Any Ptr = ToBStr(sname)
   dmobj->lpvtbl->DelEnv(dmobj, index, tStr, @nRet)
   SysFreeString(tStr)
   Return nRet
End Function

Function dmsoft.GetPath() As ZString Ptr
   If sRet Then
      SysFreeString(sRet)
   EndIf
   dmobj->lpvtbl->GetPath(dmobj, @sRet)
   Return W2A(sRet)
End Function

Function dmsoft.SetDict(index As Integer, dict_name As ZString Ptr) As Integer
   Dim tStr As Any Ptr = ToBStr(dict_name)
   dmobj->lpvtbl->SetDict(dmobj, index, tStr, @nRet)
   SysFreeString(tStr)
   Return nRet
End Function

Function dmsoft.FindPic(x1 As Integer, y1 As Integer, x2 As Integer, y2 As Integer, pic_name As ZString Ptr, delta_color As ZString Ptr, sim As Double, iDir As Integer, ByRef x As Integer, ByRef y As Integer) As Integer
   Dim As VARIANT tx, ty
   Dim tpStr As Any Ptr = ToBStr(pic_name)
   Dim tcStr As Any Ptr = ToBStr(delta_color)
   dmobj->lpvtbl->FindPic(dmobj, x1, y1, x2, y2, tpStr, tcStr, sim, iDir, @tx, @ty, @nRet)
   x = tx.lVal
   y = ty.lVal
   SysFreeString(tpStr)
   SysFreeString(tcStr)
   Return nRet
End Function

Function dmsoft.FindPicEx(x1 As Integer, y1 As Integer, x2 As Integer, y2 As Integer, pic_name As ZString Ptr, delta_color As ZString Ptr, sim As Double, iDir As Integer) As ZString Ptr
   If sRet Then
      SysFreeString(sRet)
   EndIf
   Dim tpStr As Any Ptr = ToBStr(pic_name)
   Dim tcStr As Any Ptr = ToBStr(delta_color)
   dmobj->lpvtbl->FindPicEx(dmobj, x1, y1, x2, y2, tpStr, tcStr, sim, iDir, @sRet)
   SysFreeString(tpStr)
   SysFreeString(tcStr)
   Return W2A(sRet)
End Function

Function dmsoft.SetClientSize(hWin As HWND, w As Integer, h As Integer) As Integer
   dmobj->lpvtbl->SetClientSize(dmobj, Cast(Integer, hWin), w, h, @nRet)
   Return nRet
End Function

Function dmsoft.ReadInt(hWin As HWND, addr As ZString Ptr, tpe As Integer) As Integer
   Dim tStr As Any Ptr = ToBStr(addr)
   dmobj->lpvtbl->ReadInt(dmobj, Cast(Integer, hWin), tStr, tpe, @nRet)
   SysFreeString(tStr)
   Return nRet
End Function

Function dmsoft.ReadFloat(hWin As HWND, addr As ZString Ptr) As Single
   Dim tStr As Any Ptr = ToBStr(addr)
   dmobj->lpvtbl->ReadFloat(dmobj, Cast(Integer, hWin), tStr, @fRet)
   SysFreeString(tStr)
   Return fRet
End Function

Function dmsoft.ReadDouble(hWin As HWND, addr As ZString Ptr) As Double
   Dim tStr As Any Ptr = ToBStr(addr)
   dmobj->lpvtbl->ReadDouble(dmobj, Cast(Integer, hWin), tStr, @dRet)
   SysFreeString(tStr)
   Return dRet
End Function

Function dmsoft.FindInt(hWin As HWND, addr_range As ZString Ptr, int_value_min As Integer, int_value_max As Integer, tpe As Integer) As ZString Ptr
   If sRet Then
      SysFreeString(sRet)
   EndIf
   Dim tStr As Any Ptr = ToBStr(addr_range)
   dmobj->lpvtbl->FindInt(dmobj, Cast(Integer, hWin), tStr, int_value_min, int_value_max, tpe, @sRet)
   SysFreeString(tStr)
   Return W2A(sRet)
End Function

Function dmsoft.FindFloat(hWin As HWND, addr_range As ZString Ptr, float_value_min As Single, float_value_max As Single) As ZString Ptr
   If sRet Then
      SysFreeString(sRet)
   EndIf
   Dim tStr As Any Ptr = ToBStr(addr_range)
   dmobj->lpvtbl->FindFloat(dmobj, Cast(Integer, hWin), tStr, float_value_min, float_value_max, @sRet)
   SysFreeString(tStr)
   Return W2A(sRet)
End Function

Function dmsoft.FindDouble(hWin As HWND, addr_range As ZString Ptr, double_value_min As Double, double_value_max As Double) As ZString Ptr
   If sRet Then
      SysFreeString(sRet)
   EndIf
   Dim tStr As Any Ptr = ToBStr(addr_range)
   dmobj->lpvtbl->FindDouble(dmobj, Cast(Integer, hWin), tStr, double_value_min, double_value_max, @sRet)
   SysFreeString(tStr)
   Return W2A(sRet)
End Function

Function dmsoft.FindString(hWin As HWND, addr_range As ZString Ptr, string_value As ZString Ptr, tpe As Integer) As ZString Ptr
   If sRet Then
      SysFreeString(sRet)
   EndIf
   Dim taStr As Any Ptr = ToBStr(addr_range)
   Dim tvStr As Any Ptr = ToBStr(string_value)
   dmobj->lpvtbl->FindString(dmobj, Cast(Integer, hWin), taStr, tvStr, tpe, @sRet)
   SysFreeString(taStr)
   SysFreeString(tvStr)
   Return W2A(sRet)
End Function

Function dmsoft.GetModuleBaseAddr(hWin As HWND, module_name As ZString Ptr) As Integer
   Dim tStr As Any Ptr = ToBStr(module_name)
   dmobj->lpvtbl->GetModuleBaseAddr(dmobj, Cast(Integer, hWin), tStr, @nRet)
   SysFreeString(tStr)
   Return nRet
End Function

Function dmsoft.MoveToEx(x As Integer, y As Integer, w As Integer, h As Integer) As ZString Ptr
   If sRet Then
      SysFreeString(sRet)
   EndIf
   dmobj->lpvtbl->MoveToEx(dmobj, x, y, w, h, @sRet)
   Return W2A(sRet)
End Function

Function dmsoft.MatchPicName(pic_name As ZString Ptr) As ZString Ptr
   If sRet Then
      SysFreeString(sRet)
   EndIf
   Dim tStr As Any Ptr = ToBStr(pic_name)
   dmobj->lpvtbl->MatchPicName(dmobj, tStr, @sRet)
   SysFreeString(tStr)
   Return W2A(sRet)
End Function

Function dmsoft.AddDict(index As Integer, dict_info As ZString Ptr) As Integer
   Dim tStr As Any Ptr = ToBStr(dict_info)
   dmobj->lpvtbl->AddDict(dmobj, index, tStr, @nRet)
   SysFreeString(tStr)
   Return nRet
End Function

Function dmsoft.EnterCri() As Integer
   dmobj->lpvtbl->EnterCri(dmobj, @nRet)
   Return nRet
End Function

Function dmsoft.LeaveCri() As Integer
   dmobj->lpvtbl->LeaveCri(dmobj, @nRet)
   Return nRet
End Function

Function dmsoft.WriteInt(hWin As HWND, addr As ZString Ptr, tpe As Integer, v As Integer) As Integer
   Dim tStr As Any Ptr = ToBStr(addr)
   dmobj->lpvtbl->WriteInt(dmobj, Cast(Integer, hWin), tStr, tpe, v, @nRet)
   SysFreeString(tStr)
   Return nRet
End Function

Function dmsoft.WriteFloat(hWin As HWND, addr As ZString Ptr, v As Single) As Integer
   Dim tStr As Any Ptr = ToBStr(addr)
   dmobj->lpvtbl->WriteFloat(dmobj, Cast(Integer, hWin), tStr, v, @nRet)
   SysFreeString(tStr)
   Return nRet
End Function

Function dmsoft.WriteDouble(hWin As HWND, addr As ZString Ptr, v As Double) As Integer
   Dim tStr As Any Ptr = ToBStr(addr)
   dmobj->lpvtbl->WriteDouble(dmobj, Cast(Integer, hWin), tStr, v, @nRet)
   SysFreeString(tStr)
   Return nRet
End Function

Function dmsoft.WriteString(hWin As HWND, addr As ZString Ptr, tpe As Integer, v As ZString Ptr) As Integer
   Dim taStr As Any Ptr = ToBStr(addr)
   Dim tvStr As Any Ptr = ToBStr(addr)
   dmobj->lpvtbl->WriteString(dmobj, Cast(Integer, hWin), taStr, tpe, tvStr, @nRet)
   SysFreeString(taStr)
   SysFreeString(tvStr)
   Return nRet
End Function

Function dmsoft.AsmAdd(asm_ins As ZString Ptr) As Integer
   Dim tStr As Any Ptr = ToBStr(asm_ins)
   dmobj->lpvtbl->AsmAdd(dmobj, tStr, @nRet)
   Return nRet
End Function

Function dmsoft.AsmClear() As Integer
   dmobj->lpvtbl->AsmClear(dmobj, @nRet)
   Return nRet
End Function

Function dmsoft.AsmCall(hWin As HWND, mode As Integer) As Integer
   dmobj->lpvtbl->AsmCall(dmobj, Cast(Integer,hWin), mode, @nRet)
   Return nRet
End Function

Function dmsoft.FindMultiColor(x1 As Integer, y1 As Integer, x2 As Integer, y2 As Integer, first_color As ZString Ptr, offset_color As ZString Ptr, sim As Double, iDir As Integer, ByRef x As Integer, ByRef y As Integer) As Integer
   Dim As VARIANT tx, ty
   Dim tfStr As Any Ptr = ToBStr(first_color)
   Dim toStr As Any Ptr = ToBStr(offset_color)
   dmobj->lpvtbl->FindMultiColor(dmobj, x1, y1, x2, y2, tfStr, toStr, sim, iDir, @tx, @ty, @nRet)
   x = tx.lVal
   y = ty.lVal
   SysFreeString(tfStr)
   SysFreeString(toStr)
   Return nRet
End Function

Function dmsoft.FindMultiColorEx(x1 As Integer, y1 As Integer, x2 As Integer, y2 As Integer, first_color As ZString Ptr, offset_color As ZString Ptr, sim As Double, iDir As Integer) As ZString Ptr
   If sRet Then
      SysFreeString(sRet)
   EndIf
   Dim tfStr As Any Ptr = ToBStr(first_color)
   Dim toStr As Any Ptr = ToBStr(offset_color)
   dmobj->lpvtbl->FindMultiColorEx(dmobj, x1, y1, x2, y2, tfStr, toStr, sim, iDir, @sRet)
   SysFreeString(tfStr)
   SysFreeString(toStr)
   Return W2A(sRet)
End Function

Function dmsoft.AsmCode(base_addr As Integer) As ZString Ptr
   If sRet Then
      SysFreeString(sRet)
   EndIf
   dmobj->lpvtbl->AsmCode(dmobj, base_addr, @sRet)
   Return W2A(sRet)
End Function

Function dmsoft.Assemble(asm_code As ZString Ptr, base_addr As Integer, is_upper As Integer) As ZString Ptr
   If sRet Then
      SysFreeString(sRet)
   EndIf
   Dim tStr As Any Ptr = ToBStr(asm_code)
   dmobj->lpvtbl->Assemble(dmobj, tStr, base_addr, is_upper, @sRet)
   SysFreeString(tStr)
   Return W2A(sRet)
End Function

Function dmsoft.SetWindowTransparent(hWin As HWND, v As Integer) As Integer
   dmobj->lpvtbl->SetWindowTransparent(dmobj, Cast(Integer, hWin), v, @nRet)
   Return nRet
End Function

Function dmsoft.ReadData(hWin As HWND, addr As ZString Ptr, nLen As Integer) As ZString Ptr
   If sRet Then
      SysFreeString(sRet)
   EndIf
   Dim tStr As Any Ptr = ToBStr(addr)
   dmobj->lpvtbl->ReadData(dmobj, Cast(Integer, hWin), tStr, nLen, @sRet)
   SysFreeString(tStr)
   Return W2A(sRet)
End Function

Function dmsoft.WriteData(hWin As HWND, addr As ZString Ptr, pData As ZString Ptr) As Integer
   Dim taStr As Any Ptr = ToBStr(addr)
   Dim tdStr As Any Ptr = ToBStr(pData)
   dmobj->lpvtbl->WriteData(dmobj, Cast(Integer, hWin), taStr, tdStr, @nRet)
   SysFreeString(taStr)
   SysFreeString(tdStr)
   Return nRet
End Function

Function dmsoft.FindData(hWin As HWND, addr_range As ZString Ptr, pData As ZString Ptr) As ZString Ptr
   If sRet Then
      SysFreeString(sRet)
   EndIf
   Dim taStr As Any Ptr = ToBStr(addr_range)
   Dim tdStr As Any Ptr = ToBStr(pData)
   dmobj->lpvtbl->FindData(dmobj, Cast(Integer, hWin), taStr, tdStr, @sRet)
   SysFreeString(taStr)
   SysFreeString(tdStr)
   Return W2A(sRet)
End Function

Function dmsoft.SetPicPwd(pwd As ZString Ptr) As Integer
   Dim tStr As Any Ptr = ToBStr(pwd)
   dmobj->lpvtbl->SetPicPwd(dmobj, tStr, @nRet)
   Return nRet
End Function

Function dmsoft.Log(info As ZString Ptr) As Integer
   Dim tStr As Any Ptr = ToBStr(info)
   dmobj->lpvtbl->Log(dmobj, tStr, @nRet)
   Return nRet
End Function

Function dmsoft.SetExactOcr(exact_ocr As Integer) As Integer
   dmobj->lpvtbl->SetExactOcr(dmobj, exact_ocr, @nRet)
   Return nRet
End Function

Function dmsoft.ReadString(hWin As HWND, addr As ZString Ptr, tpe As Integer, nLen As Integer) As ZString Ptr
   If sRet Then
      SysFreeString(sRet)
   EndIf
   Dim tStr As Any Ptr = ToBStr(addr)
   dmobj->lpvtbl->ReadString(dmobj, Cast(Integer, hWin), tStr, tpe, nLen, @sRet)
   SysFreeString(tStr)
   Return W2A(sRet)
End Function

Function dmsoft.FoobarTextPrintDir(hWin As HWND, iDir As Integer) As Integer
   dmobj->lpvtbl->FoobarTextPrintDir(dmobj, Cast(Integer, hWin), iDir, @nRet)
   Return nRet
End Function

Function dmsoft.OcrEx(x1 As Integer, y1 As Integer, x2 As Integer, y2 As Integer, scolor As ZString Ptr, sim As Double) As ZString Ptr
   If sRet Then
      SysFreeString(sRet)
   EndIf
   Dim tStr As Any Ptr = ToBStr(scolor)
   dmobj->lpvtbl->OcrEx(dmobj, x1, y1, x2, y2, tStr, sim, @sRet)
   SysFreeString(tStr)
   Return W2A(sRet)
End Function

Function dmsoft.SetDisplayInput(mode As ZString Ptr) As Integer
   Dim tStr As Any Ptr = ToBStr(mode)
   dmobj->lpvtbl->SetDisplayInput(dmobj, tStr, @nRet)
   SysFreeString(tStr)
   Return nRet
End Function

Function dmsoft.GetTime() As Integer
   dmobj->lpvtbl->GetTime(dmobj, @nRet)
   Return nRet
End Function

Function dmsoft.GetScreenWidth() As Integer
   dmobj->lpvtbl->GetScreenWidth(dmobj, @nRet)
   Return nRet
End Function

Function dmsoft.GetScreenHeight() As Integer
   dmobj->lpvtbl->GetScreenHeight(dmobj, @nRet)
   Return nRet
End Function

Function dmsoft.BindWindowEx(hWin As HWND, display As ZString Ptr, mouse As ZString Ptr, keypad As ZString Ptr, public_desc As ZString Ptr, mode As Integer) As Integer
   Dim tdStr As Any Ptr = ToBStr(display)
   Dim tmStr As Any Ptr = ToBStr(mouse)
   Dim tkStr As Any Ptr = ToBStr(keypad)
   Dim tpStr As Any Ptr = ToBStr(public_desc)
   dmobj->lpvtbl->BindWindowEx(dmobj, Cast(Integer, hWin), tdStr, tmStr, tkStr, tpStr, mode, @nRet)
   SysFreeString(tdStr)
   SysFreeString(tmStr)
   SysFreeString(tkStr)
   SysFreeString(tpStr)
   Return nRet
End Function

Function dmsoft.GetDiskSerial() As ZString Ptr
   If sRet Then
      SysFreeString(sRet)
   EndIf
   dmobj->lpvtbl->GetDiskSerial(dmobj, @sRet)
   Return W2A(sRet)
End Function

Function dmsoft.Md5(pStr As ZString Ptr) As ZString Ptr
   If sRet Then
      SysFreeString(sRet)
   EndIf
   Dim tStr As Any Ptr = ToBStr(pStr)
   dmobj->lpvtbl->Md5(dmobj, tStr, @sRet)
   SysFreeString(tStr)
   Return W2A(sRet)
End Function

Function dmsoft.GetMac() As ZString Ptr
   If sRet Then
      SysFreeString(sRet)
   EndIf
   dmobj->lpvtbl->GetMac(dmobj, @sRet)
   Return W2A(sRet)
End Function

Function dmsoft.ActiveInputMethod(hWin As HWND, id As ZString Ptr) As Integer
   Dim tStr As Any Ptr = ToBStr(id)
   dmobj->lpvtbl->ActiveInputMethod(dmobj, Cast(Integer, hWin), tStr, @nRet)
   SysFreeString(tStr)
   Return nRet
End Function

Function dmsoft.CheckInputMethod(hWin As HWND, id As ZString Ptr) As Integer
   Dim tStr As Any Ptr = ToBStr(id)
   dmobj->lpvtbl->CheckInputMethod(dmobj, Cast(Integer, hWin), tStr, @nRet)
   SysFreeString(tStr)
   Return nRet
End Function

Function dmsoft.FindInputMethod(id As ZString Ptr) As Integer
   Dim tStr As Any Ptr = ToBStr(id)
   dmobj->lpvtbl->FindInputMethod(dmobj, tStr, @nRet)
   SysFreeString(tStr)
   Return nRet
End Function

Function dmsoft.GetCursorPos(ByRef x As Integer, ByRef y As Integer) As Integer
   Dim As VARIANT tx, ty
   dmobj->lpvtbl->GetCursorPos(dmobj, @tx, @ty, @nRet)
   x = tx.lVal
   y = ty.lVal
   Return nRet
End Function

Function dmsoft.BindWindow(hWin As HWND, display As ZString Ptr, mouse As ZString Ptr, keypad As ZString Ptr, mode As Integer) As Integer
   Dim tdStr As Any Ptr = ToBStr(display)
   Dim tmStr As Any Ptr = ToBStr(mouse)
   Dim tkStr As Any Ptr = ToBStr(keypad)
   dmobj->lpvtbl->BindWindow(dmobj, Cast(Integer, hWin), tdStr, tmStr, tkStr, mode, @nRet)
   SysFreeString(tdStr)
   SysFreeString(tmStr)
   SysFreeString(tkStr)
   Return nRet
End Function

Function dmsoft.FindWindow(class_name As ZString Ptr, title_name As ZString Ptr) As HWND
   Dim tcStr As Any Ptr = ToBStr(class_name)
   Dim ttStr As Any Ptr = ToBStr(title_name)
   dmobj->lpvtbl->FindWindow(dmobj, tcStr, ttStr, @nRet)
   SysFreeString(tcStr)
   SysFreeString(ttStr)
   Return Cast(HWND, nRet)
End Function

Function dmsoft.GetScreenDepth() As Integer
   dmobj->lpvtbl->GetScreenDepth(dmobj, @nRet)
   Return nRet
End Function

Function dmsoft.SetScreen(w As Integer, h As Integer, depth As Integer) As Integer
   dmobj->lpvtbl->SetScreen(dmobj, w, h, depth, @nRet)
   Return nRet
End Function

Function dmsoft.ExitOs(tpe As Integer) As Integer
   dmobj->lpvtbl->ExitOs(dmobj, tpe, @nRet)
   Return nRet
End Function

Function dmsoft.GetDir(tpe As Integer) As ZString Ptr
   If sRet Then
      SysFreeString(sRet)
   EndIf
   dmobj->lpvtbl->GetDir(dmobj, tpe, @sRet)
   Return W2A(sRet)
End Function

Function dmsoft.GetOsType() As Integer
   dmobj->lpvtbl->GetOsType(dmobj, @nRet)
   Return nRet
End Function

Function dmsoft.FindWindowEx(parent As HWND, class_name As ZString Ptr, title_name As ZString Ptr) As HWND
   Dim tcStr As Any Ptr = ToBStr(class_name)
   Dim ttStr As Any Ptr = ToBStr(title_name)
   dmobj->lpvtbl->FindWindowEx(dmobj, Cast(Integer, parent), tcStr, ttStr, @nRet)
   SysFreeString(tcStr)
   SysFreeString(ttStr)
   Return Cast(HWND, nRet)
End Function

Function dmsoft.SetExportDict(index As Integer, dict_name As ZString Ptr) As Integer
   Dim tStr As Any Ptr = ToBStr(dict_name)
   dmobj->lpvtbl->SetExportDict(dmobj, index, tStr, @nRet)
   SysFreeString(tStr)
   Return nRet
End Function

Function dmsoft.GetCursorShape() As ZString Ptr
   If sRet Then
      SysFreeString(sRet)
   EndIf
   dmobj->lpvtbl->GetCursorShape(dmobj, @sRet)
   Return W2A(sRet)
End Function

Function dmsoft.DownCpu(rate As Integer) As Integer
   dmobj->lpvtbl->DownCpu(dmobj, rate, @nRet)
   Return nRet
End Function

Function dmsoft.GetCursorSpot() As ZString Ptr
   If sRet Then
      SysFreeString(sRet)
   EndIf
   dmobj->lpvtbl->GetCursorSpot(dmobj, @sRet)
   Return W2A(sRet)
End Function

Function dmsoft.SendString2(hWin As HWND, pStr As ZString Ptr) As Integer
   Dim tStr As Any Ptr = ToBStr(pStr)
   dmobj->lpvtbl->SendString2(dmobj, Cast(Integer, hWin), tStr, @nRet)
   SysFreeString(tStr)
   Return nRet
End Function

Function dmsoft.FaqPost(server As ZString Ptr, handle As Integer, request_type As Integer, time_out As Integer) As Integer
   Dim tStr As Any Ptr = ToBStr(server)
   dmobj->lpvtbl->FaqPost(dmobj, tStr, handle, request_type, time_out, @nRet)
   SysFreeString(tStr)
   Return nRet
End Function

Function dmsoft.FaqFetch() As ZString Ptr
   If sRet Then
      SysFreeString(sRet)
   EndIf
   dmobj->lpvtbl->FaqFetch(dmobj, @sRet)
   Return W2A(sRet)
End Function

Function dmsoft.FetchWord(x1 As Integer, y1 As Integer, x2 As Integer, y2 As Integer, scolor As ZString Ptr, word As ZString Ptr) As ZString Ptr
   If sRet Then
      SysFreeString(sRet)
   EndIf
   Dim tcStr As Any Ptr = ToBStr(scolor)
   Dim twStr As Any Ptr = ToBStr(word)
   dmobj->lpvtbl->FetchWord(dmobj, x1, y1, x2, y2, tcStr, twStr, @sRet)
   SysFreeString(tcStr)
   SysFreeString(twStr)
   Return W2A(sRet)
End Function

Function dmsoft.CaptureJpg(x1 As Integer, y1 As Integer, x2 As Integer, y2 As Integer, file As ZString Ptr, quality As Integer) As Integer
   Dim tStr As Any Ptr = ToBStr(file)
   dmobj->lpvtbl->CaptureJpg(dmobj, x1, y1, x2, y2, tStr, quality, @nRet)
   SysFreeString(tStr)
   Return nRet
End Function

Function dmsoft.FindStrWithFont(x1 As Integer, y1 As Integer, x2 As Integer, y2 As Integer, pStr As ZString Ptr, scolor As ZString Ptr, sim As Double, font_name As ZString Ptr, font_size As Integer, flag As Integer, ByRef x As Integer, ByRef y As Integer) As Integer
   Dim As VARIANT tx, ty
   Dim tsStr As Any Ptr = ToBStr(pStr)
   Dim tcStr As Any Ptr = ToBStr(scolor)
   Dim tfStr As Any Ptr = ToBStr(font_name)
   dmobj->lpvtbl->FindStrWithFont(dmobj, x1, y1, x2, y2, tsStr, tcStr, sim, tfStr, font_size, flag, @tx, @ty, @nRet)
   x = tx.lVal
   y = ty.lVal
   SysFreeString(tsStr)
   SysFreeString(tcStr)
   SysFreeString(tfStr)
   Return nRet
End Function

Function dmsoft.FindStrWithFontEx(x1 As Integer, y1 As Integer, x2 As Integer, y2 As Integer, pStr As ZString Ptr, scolor As ZString Ptr, sim As Double, font_name As ZString Ptr, font_size As Integer, flag As Integer) As ZString Ptr
   If sRet Then
      SysFreeString(sRet)
   EndIf
   Dim tsStr As Any Ptr = ToBStr(pStr)
   Dim tcStr As Any Ptr = ToBStr(scolor)
   Dim tfStr As Any Ptr = ToBStr(font_name)
   dmobj->lpvtbl->FindStrWithFontEx(dmobj, x1, y1, x2, y2, tsStr, tcStr, sim, tfStr, font_size, flag, @sRet)
   SysFreeString(tsStr)
   SysFreeString(tcStr)
   SysFreeString(tfStr)
   Return W2A(sRet)
End Function

Function dmsoft.GetDictInfo(pStr As ZString Ptr, font_name As ZString Ptr, font_size As Integer, flag As Integer) As ZString Ptr
   If sRet Then
      SysFreeString(sRet)
   EndIf
   Dim tsStr As Any Ptr = ToBStr(pStr)
   Dim tfStr As Any Ptr = ToBStr(font_name)
   dmobj->lpvtbl->GetDictInfo(dmobj, tsStr, tfStr, font_size, flag, @sRet)
   SysFreeString(tsStr)
   SysFreeString(tfStr)
   Return W2A(sRet)
End Function

Function dmsoft.SaveDict(index As Integer, file As ZString Ptr) As Integer
   Dim tStr As Any Ptr = ToBStr(file)
   dmobj->lpvtbl->SaveDict(dmobj, index, tStr, @nRet)
   SysFreeString(tStr)
   Return nRet
End Function


Function dmsoft.GetWindowProcessId(hWin As HWND) As Integer
   dmobj->lpvtbl->GetWindowProcessId(dmobj, Cast(Integer, hWin), @nRet)
   Return nRet
End Function

Function dmsoft.GetWindowProcessPath(hWin As HWND) As ZString Ptr
   If sRet Then
      SysFreeString(sRet)
   EndIf
   dmobj->lpvtbl->GetWindowProcessPath(dmobj, Cast(Integer, hWin), @sRet)
   Return W2A(sRet)
End Function

Function dmsoft.LockInput(nLock As Integer) As Integer
   dmobj->lpvtbl->LockInput(dmobj, nLock, @nRet)
   Return nRet
End Function

Function dmsoft.GetPicSize(pic_name As ZString Ptr) As ZString Ptr
   If sRet Then
      SysFreeString(sRet)
   EndIf
   Dim tStr As Any Ptr = ToBStr(pic_name)
   dmobj->lpvtbl->GetPicSize(dmobj, tStr, @sRet)
   SysFreeString(tStr)
   Return W2A(sRet)
End Function

Function dmsoft.GetID() As Integer
   dmobj->lpvtbl->GetID(dmobj, @nRet)
   Return nRet
End Function

Function dmsoft.CapturePng(x1 As Integer, y1 As Integer, x2 As Integer, y2 As Integer, file As ZString Ptr) As Integer
   Dim tStr As Any Ptr = ToBStr(file)
   dmobj->lpvtbl->CapturePng(dmobj, x1, y1, x2, y2, tStr, @nRet)
   SysFreeString(tStr)
   Return nRet
End Function

Function dmsoft.CaptureGif(x1 As Integer, y1 As Integer, x2 As Integer, y2 As Integer, file As ZString Ptr, idelay As Integer, iTime As Integer) As Integer
   Dim tStr As Any Ptr = ToBStr(file)
   dmobj->lpvtbl->CaptureGif(dmobj, x1, y1, x2, y2, tStr, idelay, iTime, @nRet)
   SysFreeString(tStr)
   Return nRet
End Function

Function dmsoft.ImageToBmp(pic_name As ZString Ptr, bmp_name As ZString Ptr) As Integer
   Dim tpStr As Any Ptr = ToBStr(pic_name)
   Dim tbStr As Any Ptr = ToBStr(bmp_name)
   dmobj->lpvtbl->ImageToBmp(dmobj, tpStr, tbStr, @nRet)
   SysFreeString(tpStr)
   SysFreeString(tbStr)
   Return nRet
End Function

Function dmsoft.FindStrFast(x1 As Integer, y1 As Integer, x2 As Integer, y2 As Integer, pStr As ZString Ptr, scolor As ZString Ptr, sim As Double, ByRef x As Integer, ByRef y As Integer) As Integer
   Dim As VARIANT tx, ty
   Dim tpStr As Any Ptr = ToBStr(pStr)
   Dim tcStr As Any Ptr = ToBStr(scolor)
   dmobj->lpvtbl->FindStrFast(dmobj, x1, y1, x2, y2, tpStr, tcStr, sim, @tx, @ty, @nRet)
   x = tx.lVal
   y = ty.lVal
   SysFreeString(tpStr)
   SysFreeString(tcStr)
   Return nRet
End Function

Function dmsoft.FindStrFastEx(x1 As Integer, y1 As Integer, x2 As Integer, y2 As Integer, pStr As ZString Ptr, scolor As ZString Ptr, sim As Double) As ZString Ptr
   If sRet Then
      SysFreeString(sRet)
   EndIf
   Dim tpStr As Any Ptr = ToBStr(pStr)
   Dim tcStr As Any Ptr = ToBStr(scolor)
   dmobj->lpvtbl->FindStrFastEx(dmobj, x1, y1, x2, y2, tpStr, tcStr, sim, @sRet)
   SysFreeString(tpStr)
   SysFreeString(tcStr)
   Return W2A(sRet)
End Function

Function dmsoft.EnableDisplayDebug(enable_debug As Integer) As Integer
   dmobj->lpvtbl->EnableDisplayDebug(dmobj, enable_debug, @nRet)
   Return nRet
End Function

Function dmsoft.CapturePre(file As ZString Ptr) As Integer
   Dim tStr As Any Ptr = ToBStr(file)
   dmobj->lpvtbl->CapturePre(dmobj, tStr, @nRet)
   SysFreeString(tStr)
   Return nRet
End Function

Function dmsoft.RegEx(code As ZString Ptr, sVer As ZString Ptr, ip As ZString Ptr) As Integer
   Dim tcStr As Any Ptr = ToBStr(code)
   Dim tvStr As Any Ptr = ToBStr(sVer)
   Dim tiStr As Any Ptr = ToBStr(ip)
   dmobj->lpvtbl->RegEx(dmobj, tcStr, tvStr, tiStr, @nRet)
   SysFreeString(tcStr)
   SysFreeString(tvStr)
   SysFreeString(tiStr)
   Return nRet
End Function

Function dmsoft.GetMachineCode() As ZString Ptr
   If sRet Then
      SysFreeString(sRet)
   EndIf
   dmobj->lpvtbl->GetMachineCode(dmobj, @sRet)
   Return W2A(sRet)
End Function

Function dmsoft.SetClipboard(pData As ZString Ptr) As Integer
   Dim tStr As Any Ptr = ToBStr(pData)
   dmobj->lpvtbl->SetClipboard(dmobj, tStr, @nRet)
   SysFreeString(tStr)
   Return nRet
End Function

Function dmsoft.GetClipboard() As ZString Ptr
   If sRet Then
      SysFreeString(sRet)
   EndIf
   dmobj->lpvtbl->GetClipboard(dmobj, @sRet)
   Return W2A(sRet)
End Function

Function dmsoft.GetNowDict() As Integer
   dmobj->lpvtbl->GetNowDict(dmobj, @nRet)
   Return nRet
End Function

Function dmsoft.Is64Bit() As Integer
   dmobj->lpvtbl->Is64Bit(dmobj, @nRet)
   Return nRet
End Function

Function dmsoft.GetColorNum(x1 As Integer, y1 As Integer, x2 As Integer, y2 As Integer, scolor As ZString Ptr, sim As Double) As Integer
   Dim tStr As Any Ptr = ToBStr(scolor)
   dmobj->lpvtbl->GetColorNum(dmobj, x1, y1, x2, y2, tStr, sim, @nRet)
   SysFreeString(tStr)
   Return nRet
End Function

Function dmsoft.EnumWindowByProcess(process_name As ZString Ptr, title As ZString Ptr, class_name As ZString Ptr, filter As Integer) As ZString Ptr
   If sRet Then
      SysFreeString(sRet)
   EndIf
   Dim tpStr As Any Ptr = ToBStr(process_name)
   Dim ttStr As Any Ptr = ToBStr(title)
   Dim tcStr As Any Ptr = ToBStr(class_name)
   dmobj->lpvtbl->EnumWindowByProcess(dmobj, tpStr, ttStr, tcStr, filter, @sRet)
   SysFreeString(tpStr)
   SysFreeString(ttStr)
   SysFreeString(tcStr)
   Return W2A(sRet)
End Function

Function dmsoft.GetDictCount(index As Integer) As Integer
   dmobj->lpvtbl->GetDictCount(dmobj, index, @nRet)
   Return nRet
End Function

Function dmsoft.GetLastError() As Integer
   dmobj->lpvtbl->GetLastError(dmobj, @nRet)
   Return nRet
End Function

Function dmsoft.GetNetTime() As ZString Ptr
   If sRet Then
      SysFreeString(sRet)
   EndIf
   dmobj->lpvtbl->GetNetTime(dmobj, @sRet)
   Return W2A(sRet)
End Function

Function dmsoft.EnableGetColorByCapture(en As Integer) As Integer
   dmobj->lpvtbl->EnableGetColorByCapture(dmobj, en, @nRet)
   Return nRet
End Function

Function dmsoft.CheckUAC() As Integer
   dmobj->lpvtbl->CheckUAC(dmobj, @nRet)
   Return nRet
End Function

Function dmsoft.SetUAC(uac As Integer) As Integer
   dmobj->lpvtbl->SetUAC(dmobj, uac, @nRet)
   Return nRet
End Function

Function dmsoft.DisableFontSmooth() As Integer
   dmobj->lpvtbl->DisableFontSmooth(dmobj, @nRet)
   Return nRet
End Function

Function dmsoft.CheckFontSmooth() As Integer
   dmobj->lpvtbl->CheckFontSmooth(dmobj, @nRet)
   Return nRet
End Function

Function dmsoft.SetDisplayAcceler(level As Integer) As Integer
   dmobj->lpvtbl->SetDisplayAcceler(dmobj, level, @nRet)
   Return nRet
End Function

Function dmsoft.FindWindowByProcess(process_name As ZString Ptr, class_name As ZString Ptr, title_name As ZString Ptr) As Integer
   Dim tpStr As Any Ptr = ToBStr(process_name)
   Dim tcStr As Any Ptr = ToBStr(class_name)
   Dim ttStr As Any Ptr = ToBStr(title_name)
   dmobj->lpvtbl->FindWindowByProcess(dmobj, tpStr, tcStr, ttStr, @nRet)
   SysFreeString(tpStr)
   SysFreeString(tcStr)
   SysFreeString(ttStr)
   Return nRet
End Function

Function dmsoft.FindWindowByProcessId(process_id As Integer, class_name As ZString Ptr, title_name As ZString Ptr) As Integer
   Dim tcStr As Any Ptr = ToBStr(class_name)
   Dim ttStr As Any Ptr = ToBStr(title_name)
   dmobj->lpvtbl->FindWindowByProcessId(dmobj, process_id, tcStr, ttStr, @nRet)
   SysFreeString(tcStr)
   SysFreeString(ttStr)
   Return nRet
End Function

Function dmsoft.ReadIni(section As ZString Ptr, key As ZString Ptr, file As ZString Ptr) As ZString Ptr
   If sRet Then
      SysFreeString(sRet)
   EndIf
   Dim tsStr As Any Ptr = ToBStr(section)
   Dim tkStr As Any Ptr = ToBStr(key)
   Dim tfStr As Any Ptr = ToBStr(file)
   dmobj->lpvtbl->ReadIni(dmobj, tsStr, tkStr, tfStr, @sRet)
   SysFreeString(tsStr)
   SysFreeString(tkStr)
   SysFreeString(tfStr)
   Return W2A(sRet)
End Function

Function dmsoft.WriteIni(section As ZString Ptr, key As ZString Ptr, v As ZString Ptr, file As ZString Ptr) As Integer
   Dim tsStr As Any Ptr = ToBStr(section)
   Dim tkStr As Any Ptr = ToBStr(key)
   Dim tvStr As Any Ptr = ToBStr(v)
   Dim tfStr As Any Ptr = ToBStr(file)
   dmobj->lpvtbl->WriteIni(dmobj, tsStr, tkStr, tvStr, tfStr, @nRet)
   SysFreeString(tsStr)
   SysFreeString(tkStr)
   SysFreeString(tvStr)
   SysFreeString(tfStr)
   Return nRet
End Function

Function dmsoft.RunApp(path As ZString Ptr, mode As Integer) As Integer
   Dim tStr As Any Ptr = ToBStr(path)
   dmobj->lpvtbl->RunApp(dmobj, tStr, mode, @nRet)
   SysFreeString(tStr)
   Return nRet
End Function

Function dmsoft.delay(mis As Integer) As Integer
   dmobj->lpvtbl->delay(dmobj, mis, @nRet)
   Return nRet
End Function

Function dmsoft.FindWindowSuper(spec1 As ZString Ptr, flag1 As Integer, type1 As Integer, spec2 As ZString Ptr, flag2 As Integer, type2 As Integer) As Integer
   Dim t1Str As Any Ptr = ToBStr(spec1)
   Dim t2Str As Any Ptr = ToBStr(spec2)
   dmobj->lpvtbl->FindWindowSuper(dmobj, t1Str, flag1, type1, t2Str, flag2, type2, @nRet)
   SysFreeString(t1Str)
   SysFreeString(t2Str)
   Return nRet
End Function

Function dmsoft.ExcludePos(all_pos As ZString Ptr, tpe As Integer, x1 As Integer, y1 As Integer, x2 As Integer, y2 As Integer) As ZString Ptr
   If sRet Then
      SysFreeString(sRet)
   EndIf
   Dim tStr As Any Ptr = ToBStr(all_pos)
   dmobj->lpvtbl->ExcludePos(dmobj, tStr, tpe, x1, y1, x2, y2, @sRet)
   SysFreeString(tStr)
   Return W2A(sRet)
End Function

Function dmsoft.FindNearestPos(all_pos As ZString Ptr, tpe As Integer, x As Integer, y As Integer) As ZString Ptr
   If sRet Then
      SysFreeString(sRet)
   EndIf
   Dim tStr As Any Ptr = ToBStr(all_pos)
   dmobj->lpvtbl->FindNearestPos(dmobj, tStr, tpe, x, y, @sRet)
   SysFreeString(tStr)
   Return W2A(sRet)
End Function

Function dmsoft.SortPosDistance(all_pos As ZString Ptr, tpe As Integer, x As Integer, y As Integer) As ZString Ptr
   If sRet Then
      SysFreeString(sRet)
   EndIf
   Dim tStr As Any Ptr = ToBStr(all_pos)
   dmobj->lpvtbl->SortPosDistance(dmobj, tStr, tpe, x, y, @sRet)
   SysFreeString(tStr)
   Return W2A(sRet)
End Function

Function dmsoft.FindPicMem(x1 As Integer, y1 As Integer, x2 As Integer, y2 As Integer, pic_info As ZString Ptr, delta_color As ZString Ptr, sim As Double, iDir As Integer, ByRef x As Integer, ByRef y As Integer) As Integer
   Dim As VARIANT tx, ty
   Dim tpStr As Any Ptr = ToBStr(pic_info)
   Dim tcStr As Any Ptr = ToBStr(delta_color)
   dmobj->lpvtbl->FindPicMem(dmobj, x1, y1, x2, y2, tpStr, tcStr, sim, iDir, @tx, @ty, @nRet)
   x = tx.lVal
   y = ty.lVal
   SysFreeString(tpStr)
   SysFreeString(tcStr)
   Return nRet
End Function

Function dmsoft.FindPicMemEx(x1 As Integer, y1 As Integer, x2 As Integer, y2 As Integer, pic_info As ZString Ptr, delta_color As ZString Ptr, sim As Double, iDir As Integer) As ZString Ptr
   If sRet Then
      SysFreeString(sRet)
   EndIf
   Dim tpStr As Any Ptr = ToBStr(pic_info)
   Dim tcStr As Any Ptr = ToBStr(delta_color)
   dmobj->lpvtbl->FindPicMemEx(dmobj, x1, y1, x2, y2, tpStr, tcStr, sim, iDir, @sRet)
   SysFreeString(tpStr)
   SysFreeString(tcStr)
   Return W2A(sRet)
End Function

Function dmsoft.AppendPicAddr(pic_info As ZString Ptr, addr As Integer, size As Integer) As ZString Ptr
   If sRet Then
      SysFreeString(sRet)
   EndIf
   Dim tStr As Any Ptr = ToBStr(pic_info)
   dmobj->lpvtbl->AppendPicAddr(dmobj, tStr, addr, size, @sRet)
   SysFreeString(tStr)
   Return W2A(sRet)
End Function

Function dmsoft.WriteFile(file As ZString Ptr, content As ZString Ptr) As Integer
   Dim tfStr As Any Ptr = ToBStr(file)
   Dim ttStr As Any Ptr = ToBStr(content)
   dmobj->lpvtbl->WriteFile(dmobj, tfStr, ttStr, @nRet)
   SysFreeString(tfStr)
   SysFreeString(ttStr)
   Return nRet
End Function

Function dmsoft.Stop(id As Integer) As Integer
   dmobj->lpvtbl->Stop(dmobj, id, @nRet)
   Return nRet
End Function

Function dmsoft.SetDictMem(index As Integer, addr As Integer, size As Integer) As Integer
   dmobj->lpvtbl->SetDictMem(dmobj, index, addr, size, @nRet)
   Return nRet
End Function

Function dmsoft.GetNetTimeSafe() As ZString Ptr
   If sRet Then
      SysFreeString(sRet)
   EndIf
   dmobj->lpvtbl->GetNetTimeSafe(dmobj, @sRet)
   Return W2A(sRet)
End Function

Function dmsoft.ForceUnBindWindow(hWin As HWND) As Integer
   dmobj->lpvtbl->ForceUnBindWindow(dmobj, Cast(Integer, hWin), @nRet)
   Return nRet
End Function

Function dmsoft.ReadIniPwd(section As ZString Ptr, key As ZString Ptr, file As ZString Ptr, pwd As ZString Ptr) As ZString Ptr
   If sRet Then
      SysFreeString(sRet)
   EndIf
   Dim tsStr As Any Ptr = ToBStr(section)
   Dim tkStr As Any Ptr = ToBStr(key)
   Dim tfStr As Any Ptr = ToBStr(file)
   Dim tpStr As Any Ptr = ToBStr(pwd)
   dmobj->lpvtbl->ReadIniPwd(dmobj, tsStr, tkStr, tfStr, tpStr, @sRet)
   SysFreeString(tsStr)
   SysFreeString(tkStr)
   SysFreeString(tfStr)
   SysFreeString(tpStr)
   Return W2A(sRet)
End Function

Function dmsoft.WriteIniPwd(section As ZString Ptr, key As ZString Ptr, v As ZString Ptr, file As ZString Ptr, pwd As ZString Ptr) As Integer
   Dim tsStr As Any Ptr = ToBStr(section)
   Dim tkStr As Any Ptr = ToBStr(key)
   Dim tvStr As Any Ptr = ToBStr(v)
   Dim tfStr As Any Ptr = ToBStr(file)
   Dim tpStr As Any Ptr = ToBStr(pwd)
   dmobj->lpvtbl->WriteIniPwd(dmobj, tsStr, tkStr, tvStr, tfStr, tpStr, @nRet)
   SysFreeString(tsStr)
   SysFreeString(tkStr)
   SysFreeString(tvStr)
   SysFreeString(tfStr)
   SysFreeString(tpStr)
   Return nRet
End Function

Function dmsoft.DecodeFile(file As ZString Ptr, pwd As ZString Ptr) As Integer
   Dim tfStr As Any Ptr = ToBStr(file)
   Dim tpStr As Any Ptr = ToBStr(pwd)
   dmobj->lpvtbl->DecodeFile(dmobj, tfStr, tpStr, @nRet)
   SysFreeString(tfStr)
   SysFreeString(tpStr)
   Return nRet
End Function

Function dmsoft.KeyDownChar(key_str As ZString Ptr) As Integer
   Dim tStr As Any Ptr = ToBStr(key_str)
   dmobj->lpvtbl->KeyDownChar(dmobj, tStr, @nRet)
   SysFreeString(tStr)
   Return nRet
End Function

Function dmsoft.KeyUpChar(key_str As ZString Ptr) As Integer
   Dim tStr As Any Ptr = ToBStr(key_str)
   dmobj->lpvtbl->KeyUpChar(dmobj, tStr, @nRet)
   SysFreeString(tStr)
   Return nRet
End Function

Function dmsoft.KeyPressChar(key_str As ZString Ptr) As Integer
   Dim tStr As Any Ptr = ToBStr(key_str)
   dmobj->lpvtbl->KeyPressChar(dmobj, tStr, @nRet)
   SysFreeString(tStr)
   Return nRet
End Function

Function dmsoft.KeyPressStr(key_str As ZString Ptr, idelay As Integer) As Integer
   Dim tStr As Any Ptr = ToBStr(key_str)
   dmobj->lpvtbl->KeyPressStr(dmobj, tStr, idelay, @nRet)
   SysFreeString(tStr)
   Return nRet
End Function

Function dmsoft.EnableKeypadPatch(en As Integer) As Integer
   dmobj->lpvtbl->EnableKeypadPatch(dmobj, en, @nRet)
   Return nRet
End Function

Function dmsoft.EnableKeypadSync(en As Integer, time_out As Integer) As Integer
   dmobj->lpvtbl->EnableKeypadSync(dmobj, en, time_out, @nRet)
   Return nRet
End Function

Function dmsoft.EnableMouseSync(en As Integer, time_out As Integer) As Integer
   dmobj->lpvtbl->EnableMouseSync(dmobj, en, time_out, @nRet)
   Return nRet
End Function

Function dmsoft.DmGuard(en As Integer, tpe As ZString Ptr) As Integer
   Dim tStr As Any Ptr = ToBStr(tpe)
   dmobj->lpvtbl->DmGuard(dmobj, en, tStr, @nRet)
   SysFreeString(tStr)
   Return nRet
End Function

Function dmsoft.FaqCaptureFromFile(x1 As Integer, y1 As Integer, x2 As Integer, y2 As Integer, file As ZString Ptr, quality As Integer) As Integer
   If sRet Then
      SysFreeString(sRet)
   EndIf
   Dim tStr As Any Ptr = ToBStr(file)
   dmobj->lpvtbl->FaqCaptureFromFile(dmobj, x1, y1, x2, y2, tStr, quality, @nRet)
   SysFreeString(tStr)
   Return nRet
End Function

Function dmsoft.FindIntEx(hWin As HWND, addr_range As ZString Ptr, int_value_min As Integer, int_value_max As Integer, tpe As Integer, Stp As Integer, multi_thread As Integer, mode As Integer) As ZString Ptr
   If sRet Then
      SysFreeString(sRet)
   EndIf
   Dim tStr As Any Ptr = ToBStr(addr_range)
   dmobj->lpvtbl->FindIntEx(dmobj, Cast(Integer, hWin), tStr, int_value_min, int_value_max, tpe, Stp, multi_thread, mode, @sRet)
   SysFreeString(tStr)
   Return W2A(sRet)
End Function

Function dmsoft.FindFloatEx(hWin As HWND, addr_range As ZString Ptr, float_value_min As Single, float_value_max As Single, Stp As Integer, multi_thread As Integer, mode As Integer) As ZString Ptr
   If sRet Then
      SysFreeString(sRet)
   EndIf
   Dim tStr As Any Ptr = ToBStr(addr_range)
   dmobj->lpvtbl->FindFloatEx(dmobj, Cast(Integer, hWin), tStr, float_value_min, float_value_max, Stp, multi_thread, mode, @sRet)
   SysFreeString(tStr)
   Return W2A(sRet)
End Function

Function dmsoft.FindDoubleEx(hWin As HWND, addr_range As ZString Ptr, double_value_min As Double, double_value_max As Double, Stp As Integer, multi_thread As Integer, mode As Integer) As ZString Ptr
   If sRet Then
      SysFreeString(sRet)
   EndIf
   Dim tStr As Any Ptr = ToBStr(addr_range)
   dmobj->lpvtbl->FindDoubleEx(dmobj, Cast(Integer, hWin), tStr, double_value_min, double_value_max, Stp, multi_thread, mode, @sRet)
   SysFreeString(tStr)
   Return W2A(sRet)
End Function

Function dmsoft.FindStringEx(hWin As HWND, addr_range As ZString Ptr, string_value As ZString Ptr, tpe As Integer, Stp As Integer, multi_thread As Integer, mode As Integer) As ZString Ptr
   If sRet Then
      SysFreeString(sRet)
   EndIf
   Dim taStr As Any Ptr = ToBStr(addr_range)
   Dim tvStr As Any Ptr = ToBStr(string_value)
   dmobj->lpvtbl->FindStringEx(dmobj, Cast(Integer, hWin), taStr, tvStr, tpe, Stp, multi_thread, mode, @sRet)
   SysFreeString(taStr)
   SysFreeString(tvStr)
   Return W2A(sRet)
End Function

Function dmsoft.FindDataEx(hWin As HWND, addr_range As ZString Ptr, pData As ZString Ptr, stp As Integer, multi_thread As Integer, mode As Integer) As ZString Ptr
   If sRet Then
      SysFreeString(sRet)
   EndIf
   Dim taStr As Any Ptr = ToBStr(addr_range)
   Dim tdStr As Any Ptr = ToBStr(pData)
   dmobj->lpvtbl->FindDataEx(dmobj, Cast(Integer, hWin), taStr, tdStr, stp, multi_thread, mode, @sRet)
   SysFreeString(taStr)
   SysFreeString(tdStr)
   Return W2A(sRet)
End Function

Function dmsoft.EnableRealMouse(en As Integer, mousedelay As Integer, mousestep As Integer) As Integer
   dmobj->lpvtbl->EnableRealMouse(dmobj, en, mousedelay, mousestep, @nRet)
   Return nRet
End Function

Function dmsoft.EnableRealKeypad(en As Integer) As Integer
   dmobj->lpvtbl->EnableRealKeypad(dmobj, en, @nRet)
   Return nRet
End Function

Function dmsoft.SendStringIme(pStr As ZString Ptr) As Integer
   Dim tStr As Any Ptr = ToBStr(pStr)
   dmobj->lpvtbl->SendStringIme(dmobj, tStr, @nRet)
   SysFreeString(tStr)
   Return nRet
End Function

Function dmsoft.FoobarDrawLine(hWin As HWND, x1 As Integer, y1 As Integer, x2 As Integer, y2 As Integer, scolor As ZString Ptr, style As Integer, w As Integer) As Integer
   Dim tStr As Any Ptr = ToBStr(scolor)
   dmobj->lpvtbl->FoobarDrawLine(dmobj, Cast(Integer, hWin), x1, y1, x2, y2, tStr, style, w, @nRet)
   SysFreeString(tStr)
   Return nRet
End Function

Function dmsoft.FindStrEx(x1 As Integer, y1 As Integer, x2 As Integer, y2 As Integer, pStr As ZString Ptr, scolor As ZString Ptr, sim As Double) As ZString Ptr
   If sRet Then
      SysFreeString(sRet)
   EndIf
   Dim tpStr As Any Ptr = ToBStr(pStr)
   Dim tcStr As Any Ptr = ToBStr(scolor)
   dmobj->lpvtbl->FindStrEx(dmobj, x1, y1, x2, y2, tpStr, tcStr, sim, @sRet)
   SysFreeString(tpStr)
   SysFreeString(tcStr)
   Return W2A(sRet)
End Function

Function dmsoft.IsBind(hWin As HWND) As Integer
   dmobj->lpvtbl->IsBind(dmobj, Cast(Integer, hWin), @nRet)
   Return nRet
End Function

Function dmsoft.SetDisplayDelay(t As Integer) As Integer
   dmobj->lpvtbl->SetDisplayDelay(dmobj, t, @nRet)
   Return nRet
End Function

Function dmsoft.GetDmCount() As Integer
   dmobj->lpvtbl->GetDmCount(dmobj, @nRet)
   Return nRet
End Function

Function dmsoft.DisableScreenSave() As Integer
   dmobj->lpvtbl->DisableScreenSave(dmobj, @nRet)
   Return nRet
End Function

Function dmsoft.DisablePowerSave() As Integer
   dmobj->lpvtbl->DisablePowerSave(dmobj, @nRet)
   Return nRet
End Function

Function dmsoft.SetMemoryHwndAsProcessId(en As Integer) As Integer
   dmobj->lpvtbl->SetMemoryHwndAsProcessId(dmobj, en, @nRet)
   Return nRet
End Function

Function dmsoft.FindShape(x1 As Integer, y1 As Integer, x2 As Integer, y2 As Integer, offset_color As ZString Ptr, sim As Double, iDir As Integer, ByRef x As Integer, ByRef y As Integer) As Integer
   Dim As VARIANT tx, ty
   Dim tStr As Any Ptr = ToBStr(offset_color)
   dmobj->lpvtbl->FindShape(dmobj, x1, y1, x2, y2, tStr, sim, iDir, @tx, @ty, @nRet)
   x = tx.lVal
   y = ty.lVal
   SysFreeString(tStr)
   Return nRet
End Function

Function dmsoft.FindShapeEx(x1 As Integer, y1 As Integer, x2 As Integer, y2 As Integer, offset_color As ZString Ptr, sim As Double, iDir As Integer) As ZString Ptr
   If sRet Then
      SysFreeString(sRet)
   EndIf
   Dim tStr As Any Ptr = ToBStr(offset_color)
   dmobj->lpvtbl->FindShapeEx(dmobj, x1, y1, x2, y2, tStr, sim, iDir, @sRet)
   SysFreeString(tStr)
   Return W2A(sRet)
End Function

Function dmsoft.FindStrS(x1 As Integer, y1 As Integer, x2 As Integer, y2 As Integer, pStr As ZString Ptr, scolor As ZString Ptr, sim As Double, ByRef x As Integer, ByRef y As Integer) As ZString Ptr
   If sRet Then
      SysFreeString(sRet)
   EndIf
   Dim As VARIANT tx, ty
   Dim tpStr As Any Ptr = ToBStr(pStr)
   Dim tcStr As Any Ptr = ToBStr(scolor)
   dmobj->lpvtbl->FindStrS(dmobj, x1, y1, x2, y2, tpStr, tcStr, sim, @tx, @ty, @sRet)
   x = tx.lVal
   y = ty.lVal
   SysFreeString(tpStr)
   SysFreeString(tcStr)
   Return W2A(sRet)
End Function

Function dmsoft.FindStrExS(x1 As Integer, y1 As Integer, x2 As Integer, y2 As Integer, pStr As ZString Ptr, scolor As ZString Ptr, sim As Double) As ZString Ptr
   If sRet Then
      SysFreeString(sRet)
   EndIf
   Dim tpStr As Any Ptr = ToBStr(pStr)
   Dim tcStr As Any Ptr = ToBStr(scolor)
   dmobj->lpvtbl->FindStrExS(dmobj, x1, y1, x2, y2, tpStr, tcStr, sim, @sRet)
   SysFreeString(tpStr)
   SysFreeString(tcStr)
   Return W2A(sRet)
End Function

Function dmsoft.FindStrFastS(x1 As Integer, y1 As Integer, x2 As Integer, y2 As Integer, pStr As ZString Ptr, scolor As ZString Ptr, sim As Double, ByRef x As Integer, ByRef y As Integer) As ZString Ptr
   If sRet Then
      SysFreeString(sRet)
   EndIf
   Dim As VARIANT tx, ty
   Dim tpStr As Any Ptr = ToBStr(pStr)
   Dim tcStr As Any Ptr = ToBStr(scolor)
   dmobj->lpvtbl->FindStrFastS(dmobj, x1, y1, x2, y2, tpStr, tcStr, sim, @tx, @ty, @sRet)
   x = tx.lVal
   y = ty.lVal
   SysFreeString(tpStr)
   SysFreeString(tcStr)
   Return W2A(sRet)
End Function

Function dmsoft.FindStrFastExS(x1 As Integer, y1 As Integer, x2 As Integer, y2 As Integer, pStr As ZString Ptr, scolor As ZString Ptr, sim As Double) As ZString Ptr
   If sRet Then
      SysFreeString(sRet)
   EndIf
   Dim tpStr As Any Ptr = ToBStr(pStr)
   Dim tcStr As Any Ptr = ToBStr(scolor)
   dmobj->lpvtbl->FindStrFastExS(dmobj, x1, y1, x2, y2, tpStr, tcStr, sim, @sRet)
   SysFreeString(tpStr)
   SysFreeString(tcStr)
   Return W2A(sRet)
End Function

Function dmsoft.FindPicS(x1 As Integer, y1 As Integer, x2 As Integer, y2 As Integer, pic_name As ZString Ptr, delta_color As ZString Ptr, sim As Double, iDir As Integer, ByRef x As Integer, ByRef y As Integer) As ZString Ptr
   If sRet Then
      SysFreeString(sRet)
   EndIf
   Dim As VARIANT tx, ty
   Dim tpStr As Any Ptr = ToBStr(pic_name)
   Dim tcStr As Any Ptr = ToBStr(delta_color)
   dmobj->lpvtbl->FindPicS(dmobj, x1, y1, x2, y2, tpStr, tcStr, sim, iDir, @tx, @ty, @sRet)
   x = tx.lVal
   y = ty.lVal
   SysFreeString(tpStr)
   SysFreeString(tcStr)
   Return W2A(sRet)
End Function

Function dmsoft.FindPicExS(x1 As Integer, y1 As Integer, x2 As Integer, y2 As Integer, pic_name As ZString Ptr, delta_color As ZString Ptr, sim As Double, iDir As Integer) As ZString Ptr
   If sRet Then
      SysFreeString(sRet)
   EndIf
   Dim tpStr As Any Ptr = ToBStr(pic_name)
   Dim tcStr As Any Ptr = ToBStr(delta_color)
   dmobj->lpvtbl->FindPicExS(dmobj, x1, y1, x2, y2, tpStr, tcStr, sim, iDir, @sRet)
   SysFreeString(tpStr)
   SysFreeString(tcStr)
   Return W2A(sRet)
End Function

Function dmsoft.ClearDict(index As Integer) As Integer
   dmobj->lpvtbl->ClearDict(dmobj, index, @nRet)
   Return nRet
End Function

Function dmsoft.GetMachineCodeNoMac() As ZString Ptr
   If sRet Then
      SysFreeString(sRet)
   EndIf
   dmobj->lpvtbl->GetMachineCodeNoMac(dmobj, @sRet)
   Return W2A(sRet)
End Function

Function dmsoft.GetClientRect(hWin As HWND, ByRef x1 As Integer, ByRef y1 As Integer, ByRef x2 As Integer, ByRef y2 As Integer) As Integer
   Dim As VARIANT tx1, ty1, tx2, ty2
   dmobj->lpvtbl->GetClientRect(dmobj, Cast(Integer, hWin), @tx1, @ty1, @tx2, @ty2, @nRet)
   x1 = tx1.lVal
   y1 = ty1.lVal
   x2 = tx2.lVal
   y2 = ty2.lVal
   Return nRet
End Function

Function dmsoft.EnableFakeActive(en As Integer) As Integer
   dmobj->lpvtbl->EnableFakeActive(dmobj, en, @nRet)
   Return nRet
End Function

Function dmsoft.GetScreenDataBmp(x1 As Integer, y1 As Integer, x2 As Integer, y2 As Integer, ByRef pData As Any Ptr, ByRef size As Integer) As Integer
   Dim As VARIANT td, ts
   dmobj->lpvtbl->GetScreenDataBmp(dmobj, x1, y1, x2, y2, @td, @ts, @nRet)
   pData = Cast(Any Ptr, td.lVal)
   size = ts.lVal
   Return nRet
End Function

Function dmsoft.EncodeFile(file As ZString Ptr, pwd As ZString Ptr) As Integer
   Dim tfStr As Any Ptr = ToBStr(file)
   Dim tpStr As Any Ptr = ToBStr(pwd)
   dmobj->lpvtbl->EncodeFile(dmobj, tfStr, tpStr, @nRet)
   SysFreeString(tfStr)
   SysFreeString(tpStr)
   Return nRet
End Function

Function dmsoft.GetCursorShapeEx(tpe As Integer) As ZString Ptr
   If sRet Then
      SysFreeString(sRet)
   EndIf
   dmobj->lpvtbl->GetCursorShapeEx(dmobj, tpe, @sRet)
   Return W2A(sRet)
End Function

Function dmsoft.FaqCancel() As Integer
   dmobj->lpvtbl->FaqCancel(dmobj, @nRet)
   Return nRet
End Function

Function dmsoft.IntToData(int_value As Integer, tpe As Integer) As ZString Ptr
   If sRet Then
      SysFreeString(sRet)
   EndIf
   dmobj->lpvtbl->IntToData(dmobj, int_value, tpe, @sRet)
   Return W2A(sRet)
End Function

Function dmsoft.FloatToData(float_value As Single) As ZString Ptr
   If sRet Then
      SysFreeString(sRet)
   EndIf
   dmobj->lpvtbl->FloatToData(dmobj, float_value, @sRet)
   Return W2A(sRet)
End Function

Function dmsoft.DoubleToData(double_value As Double) As ZString Ptr
   If sRet Then
      SysFreeString(sRet)
   EndIf
   dmobj->lpvtbl->DoubleToData(dmobj, double_value, @sRet)
   Return W2A(sRet)
End Function

Function dmsoft.StringToData(string_value As ZString Ptr, tpe As Integer) As ZString Ptr
   If sRet Then
      SysFreeString(sRet)
   EndIf
   Dim tStr As Any Ptr = ToBStr(string_value)
   dmobj->lpvtbl->StringToData(dmobj, tStr, tpe, @sRet)
   SysFreeString(tStr)
   Return W2A(sRet)
End Function

Function dmsoft.SetMemoryFindResultToFile(file As ZString Ptr) As Integer
   Dim tStr As Any Ptr = ToBStr(file)
   dmobj->lpvtbl->SetMemoryFindResultToFile(dmobj, tStr, @nRet)
   SysFreeString(tStr)
   Return nRet
End Function

Function dmsoft.EnableBind(en As Integer) As Integer
   dmobj->lpvtbl->EnableBind(dmobj, en, @nRet)
   Return nRet
End Function

Function dmsoft.SetSimMode(mode As Integer) As Integer
   dmobj->lpvtbl->SetSimMode(dmobj, mode, @nRet)
   Return nRet
End Function

Function dmsoft.LockMouseRect(x1 As Integer, y1 As Integer, x2 As Integer, y2 As Integer) As Integer
   dmobj->lpvtbl->LockMouseRect(dmobj, x1, y1, x2, y2, @nRet)
   Return nRet
End Function

Function dmsoft.SendPaste(hWin As HWND) As Integer
   dmobj->lpvtbl->SendPaste(dmobj, Cast(Integer, hWin), @nRet)
   Return nRet
End Function

Function dmsoft.IsDisplayDead(x1 As Integer, y1 As Integer, x2 As Integer, y2 As Integer, t As Integer) As Integer
   dmobj->lpvtbl->IsDisplayDead(dmobj, x1, y1, x2, y2, t, @nRet)
   Return nRet
End Function

Function dmsoft.GetKeyState(vk As Integer) As Integer
   dmobj->lpvtbl->GetKeyState(dmobj, vk, @nRet)
   Return nRet
End Function

Function dmsoft.CopyFile(src_file As ZString Ptr, dst_file As ZString Ptr, over As Integer) As Integer
   Dim tsStr As Any Ptr = ToBStr(src_file)
   Dim tdStr As Any Ptr = ToBStr(dst_file)
   dmobj->lpvtbl->CopyFile(dmobj, tsStr, tdStr, over, @nRet)
   SysFreeString(tsStr)
   SysFreeString(tdStr)
   Return nRet
End Function

Function dmsoft.IsFileExist(file As ZString Ptr) As Integer
   Dim tStr As Any Ptr = ToBStr(file)
   dmobj->lpvtbl->IsFileExist(dmobj, tStr, @nRet)
   SysFreeString(tStr)
   Return nRet
End Function

Function dmsoft.DeleteFile(file As ZString Ptr) As Integer
   Dim tStr As Any Ptr = ToBStr(file)
   dmobj->lpvtbl->DeleteFile(dmobj, tStr, @nRet)
   SysFreeString(tStr)
   Return nRet
End Function

Function dmsoft.MoveFile(src_file As ZString Ptr, dst_file As ZString Ptr) As Integer
   Dim tsStr As Any Ptr = ToBStr(src_file)
   Dim tdStr As Any Ptr = ToBStr(dst_file)
   dmobj->lpvtbl->MoveFile(dmobj, tsStr, tdStr, @nRet)
   SysFreeString(tsStr)
   SysFreeString(tdStr)
   Return nRet
End Function

Function dmsoft.CreateFolder(folder_name As ZString Ptr) As Integer
   Dim tStr As Any Ptr = ToBStr(folder_name)
   dmobj->lpvtbl->CreateFolder(dmobj, tStr, @nRet)
   SysFreeString(tStr)
   Return nRet
End Function

Function dmsoft.DeleteFolder(folder_name As ZString Ptr) As Integer
   Dim tStr As Any Ptr = ToBStr(folder_name)
   dmobj->lpvtbl->DeleteFolder(dmobj, tStr, @nRet)
   SysFreeString(tStr)
   Return nRet
End Function

Function dmsoft.GetFileLength(file As ZString Ptr) As Integer
   Dim tStr As Any Ptr = ToBStr(file)
   dmobj->lpvtbl->GetFileLength(dmobj, tStr, @nRet)
   SysFreeString(tStr)
   Return nRet
End Function

Function dmsoft.ReadFile(file As ZString Ptr) As ZString Ptr
   If sRet Then
      SysFreeString(sRet)
   EndIf
   Dim tStr As Any Ptr = ToBStr(file)
   dmobj->lpvtbl->ReadFile(dmobj, tStr, @sRet)
   SysFreeString(tStr)
   Return W2A(sRet)
End Function

Function dmsoft.WaitKey(key_code As Integer, time_out As Integer) As Integer
   dmobj->lpvtbl->WaitKey(dmobj, key_code, time_out, @nRet)
   Return nRet
End Function

Function dmsoft.DeleteIni(section As ZString Ptr, key As ZString Ptr, file As ZString Ptr) As Integer
   Dim tsStr As Any Ptr = ToBStr(section)
   Dim tkStr As Any Ptr = ToBStr(key)
   Dim tfStr As Any Ptr = ToBStr(file)
   dmobj->lpvtbl->DeleteIni(dmobj, tsStr, tkStr, tfStr, @nRet)
   SysFreeString(tsStr)
   SysFreeString(tkStr)
   SysFreeString(tfStr)
   Return nRet
End Function

Function dmsoft.DeleteIniPwd(section As ZString Ptr, key As ZString Ptr, file As ZString Ptr, pwd As ZString Ptr) As Integer
   Dim tsStr As Any Ptr = ToBStr(section)
   Dim tkStr As Any Ptr = ToBStr(key)
   Dim tfStr As Any Ptr = ToBStr(file)
   Dim tpStr As Any Ptr = ToBStr(pwd)
   dmobj->lpvtbl->DeleteIniPwd(dmobj, tsStr, tkStr, tfStr, tpStr, @nRet)
   SysFreeString(tsStr)
   SysFreeString(tkStr)
   SysFreeString(tfStr)
   SysFreeString(tpStr)
   Return nRet
End Function

Function dmsoft.EnableSpeedDx(en As Integer) As Integer
   dmobj->lpvtbl->EnableSpeedDx(dmobj, en, @nRet)
   Return nRet
End Function

Function dmsoft.EnableIme(en As Integer) As Integer
   dmobj->lpvtbl->EnableIme(dmobj, en, @nRet)
   Return nRet
End Function

Function dmsoft.Reg(code As ZString Ptr, sVer As ZString Ptr) As Integer
   Dim tcStr As Any Ptr = ToBStr(code)
   Dim tvStr As Any Ptr = ToBStr(sVer)
   dmobj->lpvtbl->Reg(dmobj, tcStr, tvStr, @nRet)
   SysFreeString(tcStr)
   SysFreeString(tvStr)
   Return nRet
End Function

Function dmsoft.SelectFile() As ZString Ptr
   If sRet Then
      SysFreeString(sRet)
   EndIf
   dmobj->lpvtbl->SelectFile(dmobj, @sRet)
   Return W2A(sRet)
End Function

Function dmsoft.SelectDirectory() As ZString Ptr
   If sRet Then
      SysFreeString(sRet)
   EndIf
   dmobj->lpvtbl->SelectDirectory(dmobj, @sRet)
   Return W2A(sRet)
End Function

Function dmsoft.LockDisplay(iLock As Integer) As Integer
   dmobj->lpvtbl->LockDisplay(dmobj, iLock, @nRet)
   Return nRet
End Function

Function dmsoft.FoobarSetSave(hWin As HWND, file As ZString Ptr, en As Integer, header As ZString Ptr) As Integer
   Dim tfStr As Any Ptr = ToBStr(file)
   Dim thStr As Any Ptr = ToBStr(header)
   dmobj->lpvtbl->FoobarSetSave(dmobj, Cast(Integer, hWin), tfStr, en, thStr, @nRet)
   SysFreeString(tfStr)
   SysFreeString(thStr)
   Return nRet
End Function

Function dmsoft.EnumWindowSuper(spec1 As ZString Ptr, flag1 As Integer, type1 As Integer, spec2 As ZString Ptr, flag2 As Integer, type2 As Integer, sort As Integer) As ZString Ptr
   If sRet Then
      SysFreeString(sRet)
   EndIf
   Dim t1Str As Any Ptr = ToBStr(spec1)
   Dim t2Str As Any Ptr = ToBStr(spec2)
   dmobj->lpvtbl->EnumWindowSuper(dmobj, t1Str, flag1, type1, t2Str, flag2, type2, sort, @sRet)
   SysFreeString(t1Str)
   SysFreeString(t2Str)
   Return W2A(sRet)
End Function

Function dmsoft.DownloadFile(url As ZString Ptr, save_file As ZString Ptr, timeout As Integer) As Integer
   Dim tuStr As Any Ptr = ToBStr(url)
   Dim tsStr As Any Ptr = ToBStr(save_file)
   dmobj->lpvtbl->DownloadFile(dmobj, tuStr, tsStr, timeout, @nRet)
   SysFreeString(tuStr)
   SysFreeString(tsStr)
   Return nRet
End Function

Function dmsoft.EnableKeypadMsg(en As Integer) As Integer
   dmobj->lpvtbl->EnableKeypadMsg(dmobj, en, @nRet)
   Return nRet
End Function

Function dmsoft.EnableMouseMsg(en As Integer) As Integer
   dmobj->lpvtbl->EnableMouseMsg(dmobj, en, @nRet)
   Return nRet
End Function

Function dmsoft.RegNoMac(code As ZString Ptr, sVer As ZString Ptr) As Integer
   Dim tcStr As Any Ptr = ToBStr(code)
   Dim tvStr As Any Ptr = ToBStr(sVer)
   dmobj->lpvtbl->RegNoMac(dmobj, tcStr, tvStr, @nRet)
   SysFreeString(tcStr)
   SysFreeString(tvStr)
   Return nRet
End Function

Function dmsoft.RegExNoMac(code As ZString Ptr, sVer As ZString Ptr, ip As ZString Ptr) As Integer
   Dim tcStr As Any Ptr = ToBStr(code)
   Dim tvStr As Any Ptr = ToBStr(sVer)
   Dim taStr As Any Ptr = ToBStr(ip)
   dmobj->lpvtbl->RegExNoMac(dmobj, tcStr, tvStr, taStr, @nRet)
   SysFreeString(tcStr)
   SysFreeString(tvStr)
   SysFreeString(taStr)
   Return nRet
End Function

Function dmsoft.SetEnumWindowDelay(idelay As Integer) As Integer
   dmobj->lpvtbl->SetEnumWindowDelay(dmobj, idelay, @nRet)
   Return nRet
End Function

Function dmsoft.FindMulColor(x1 As Integer, y1 As Integer, x2 As Integer, y2 As Integer, scolor As ZString Ptr, sim As Double) As Integer
   Dim tStr As Any Ptr = ToBStr(scolor)
   dmobj->lpvtbl->FindMulColor(dmobj, x1, y1, x2, y2, tStr, sim, @nRet)
   SysFreeString(tStr)
   Return nRet
End Function

Function dmsoft.GetDict(index As Integer, font_index As Integer) As ZString Ptr
   If sRet Then
      SysFreeString(sRet)
   EndIf
   dmobj->lpvtbl->GetDict(dmobj, index, font_index, @sRet)
   Return W2A(sRet)
End Function
